Continuation Lines Previous: The try Statement Up: Statements



Continuation Lines

In the Octave language most statements end with a newline character and you must tell Octave to ignore the newline character in order to continue a statement from one line to the next. Lines that end with the characters ... or \ are joined with the following line before they are divided into tokens by Octave's parser. For example the lines

     x = long_variable_name ...
         + longer_variable_name \
         - 42
     

form a single statement. The backslash character on the second line above is interpreted a continuation character not as a division operator.

For continuation lines that do not occur inside string constants whitespace and comments may appear between the continuation marker and the newline character. For example the statement

     x = long_variable_name ...     # comment one
         + longer_variable_name \   # comment two
         - 42                       # last comment
     

is equivalent to the one shown above. Inside string constants the continuation marker must appear at the end of the line just before the newline character.

Input that occurs inside parentheses can be continued to the next line without having to use a continuation marker. For example it is possible to write statements like

     if (fine_dining_destination == on_a_boat
         || fine_dining_destination == on_a_train)
       seuss (i will, not, eat, them, sam, i, am, i,
              will not, eat, green, eggs, and, ham);
     endif
     

without having to add to the clutter with continuation markers.