Next: , Previous: Special operators, Up: Syntax   [Contents][Index]


4.6 Expressions/Statements

Numbers and variables can be combined with the mathematical operators and logical operators to form an expression. Expressions can be used as arguments to built-in or user-defined functions (see Section Function/procedure). An expression followed by a NEWLINE prints its result on the output stream (see Section Print statement) in the default format (see Section Formatting).

For the purpose of error propagation, the print statement and the assignment operator (the '=' operator but not the ':=' operator; see Section Sub-expressions) are treated as the terminal nodes of the parsing tree which invokes the final error propagation.

Assigning a value to a variable also creates the variable. The type of the value assigned to the variable determines its type (and overrides the value or the type of a previously declared variable). E.g.

   >H_0=75pm10
   >H_0
             75.00000 +/-   10.00000
   >H_0="The Hubble constant\n"
   >H_0
    The Hubble constant

A semi-colon (';') is a delimiter to separate multiple expressions in a single line. Statements on separate lines need not be delimited by semi-colons (though it is not an error to do so). Compound statements are a group of simple statements, grouped using the curly-brace pair ('{' and '}') (e.g. {a=1.5;b=2;}). As may be obvious, compound statements can also be nested. The '/*' and '*/' pair can be used as comment delimiters. Comment delimiters however cannot be nested. %E.g.