Difference between revisions of "Language Reference/Constants"
From wiki.visual-prolog.com
m (1 revision(s)) |
m (header levels) |
||
Line 1: | Line 1: | ||
{{languageReferenceNavbar|Constants}} | {{languageReferenceNavbar|Constants}} | ||
== Constants Sections == | === Constants Sections === | ||
A <vp>constants</vp> section defines a set of constants in the current scope. | A <vp>constants</vp> section defines a set of constants in the current scope. | ||
Line 8: | Line 8: | ||
constants <ConstantDefinition>-dot-term-list-opt</vipbnf> | constants <ConstantDefinition>-dot-term-list-opt</vipbnf> | ||
== Constant Definitions == | === Constant Definitions === | ||
A constant definition defines a named constant, its type, and its value. | A constant definition defines a named constant, its type, and its value. |
Revision as of 23:07, 14 October 2008
Constants Sections
A constants section defines a set of constants in the current scope.
ConstantsSection : constants ConstantDefinition-dot-term-list-opt
Constant Definitions
A constant definition defines a named constant, its type, and its value.
ConstantDefinition: ConstantName = ConstantValue ConstantDefinition : ConstantName : TypeName = ConstantValue
ConstantName: LowerCaseIdentifier
The ConstantValue should be an expression, which can be evaluated at compile time and it should have the type of the correspondent domain. The ConstantName should be a lower case identifier lowerCaseIdentifier.
If the typeName is omitted, then the constant domain must be univocally determined by the ConstantValue expression. The typeName can be omitted only for the following built-in domains:
- Numerical (i.e. integral or real) constants. In this case, the corresponding anonymous numerical domain is adopted for a constant (see the numerical domains for details).
- Binary constants.
- String constants.
- Character constants.
Examples:
constants my_char = 'a'. true_const : boolean = true. binaryFileName = "mybin". myBinary = #bininclude(binaryFileName).