Jump to navigation Jump to search
1,271 bytes added ,  08:49, 21 August 2016
add more details about syntax imported from the contribution guidelines in the manual
== Naming ==
Use lowercase names if possible. Uppercase is acceptable for variable
names consisting of 1-2 letters. Do not use mixed case names. Function
names must be lowercase. Function names are global, so choose them
=== General naming functions ===
=== Variable names ===
== ending blocks ==
Always use a specific end-of-block statement (like {{codeline|endif}},
{{codeline|endswitch}}) rather than the generic {{codeline|end}}.
Enclose the condition of an {{codeline|if}}, {{codeline|while}}, {{codeline|until}}, or
{{codeline|switch}} statement in parentheses, as in C:
if (isvector (a))
s = sum (a);
Do not do this, however, with the iteration counter portion of a {{codeline|for}}
statement. Write:
for i = 1:n
b(i) = sum (a(:,i));
== ! operator ==
The Octave operator {{codeline|!}} should be used for logical negation, rather than
{{codeline|~}}. The negation operator is written with a space between the operator
and its target, e.g., {{codeline|! A}}.
Do not comment code out. If the code is no longer used, remove it. We use
version control, we can always bring it back.
=== %! for test and demo blocks ===
Any demos or Built-In Self Tests (BIST) using the {{codeline|%!demo}} or
{{codeline|%!test}} syntax should begin two lines after the {{codeline|endfunction}}
keyword. Demo blocks should be listed before test blocks.
See the section Writing tests on the [[Tests]] page.

Navigation menu