2.21. Constants

Constant definitions allow programmers to refer to values with Qore identifiers rather than using the value or the expression that generates the value. Constants are defined with the following syntax:

const [namespace_path::]constant_identifier = expr;

Note

As of Qore 0.8.1 and onwards, the expression used to initialize a constant can be any valid Qore expression as long as no variables are referenced. Note that the order that constants are initialized and assigned does not necessarily correspond to the declaration order, and it is bad programming practice to assign a constant with an expression that has side effects. Furthermore if an expression used to initialize a constant throws an exception, that exception cannot be caught.

Classes can also declare constants; see class constants for more information.

There are no comments yet

Leave a Comment



?
? ?
?

 
Powered by TalkBack