Language Reference/Constants

From wiki.visual-prolog.com

< Language Reference

Revision as of 15:13, 2 May 2017 by Thomas Linder Puls (talk | contribs) (TypeExpression)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

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: one of
    ConstantName = ConstantValue
    ConstantName : TypeExpression = 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.

The TypeExpression can be omitted only for the following built-in domains:

  1. 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).
  2. Binary constants.
  3. String constants.
  4. Character constants.
Example
constants
    my_char = 'a'.
    true_const : boolean = true.
    binaryFileName = "mybin".
    myBinary = #bininclude(binaryFileName).