Difference between revisions of "expression"

From Free Pascal wiki
Jump to navigationJump to search
m (→‎remarks: insert link to $extendedSyntax)
 
(2 intermediate revisions by the same user not shown)
Line 2: Line 2:
  
 
An '''expression''' is a non-productive rule that resolves by calculation into a value.
 
An '''expression''' is a non-productive rule that resolves by calculation into a value.
They consist of at least one operand, and additional operands may be linked via non-unary operators.
+
They consist of at least one operand, and additional operands may be linked via non-unary [[Operator|operators]].
 
An operand may be
 
An operand may be
 
* a literal value of any type,
 
* a literal value of any type,
Line 20: Line 20:
 
== remarks ==
 
== remarks ==
 
With [[Compiler directive|compiler directive]]
 
With [[Compiler directive|compiler directive]]
<syntaxhighlight lang="pascal" inline>{$extendedSyntax on}</syntaxhighlight> a function call as an expression can appear as a statement, too.
+
[[$extendedSyntax|<syntaxhighlight lang="pascal" inline>{$extendedSyntax on}</syntaxhighlight>]] a function call as an expression can appear as a [[statement]], too.
 
This is useful if the function triggers side-effects, but the return value is not needed.
 
This is useful if the function triggers side-effects, but the return value is not needed.
  

Latest revision as of 18:15, 25 January 2023

English (en) suomi (fi)

An expression is a non-productive rule that resolves by calculation into a value. They consist of at least one operand, and additional operands may be linked via non-unary operators. An operand may be

Examples of expressions are:

  • x + 5
  • 'Z'
  • response <> 42

Expressions, and parts thereof, can be classified by their result type. Usually primarily arithmetic and logic expressions are distinguished. An arithmetic expression results in a numeric value. A logic expression results in a Boolean value.

remarks

With compiler directive {$extendedSyntax on} a function call as an expression can appear as a statement, too. This is useful if the function triggers side-effects, but the return value is not needed.

see also