Jamie Balfour

Welcome to my personal website.

Find out more about me, my personal projects, reviews, courses and much more here.

Official ZPE/YASS documentationConstants

Constants work differently to variables in the sense that they can only be declared once. As of version 1.6.4, constants are defined using the define keyword:

YASS
define a = "Hello world"
        

Constants are then accessed by using the name of the constant:

YASS
$x = a
        

Predefined constants

ZPE provides several built in constants that can be accessed using their names:

Constant name Purpose Value Version added
Compile time constants
PI The value of π 3.141592653589793 1.3.3
PLANCK The value of Planck's constant 6.62606957-34 1.3.3
LIGHT_SPEED The value of the speed of light 2.997924588 1.3.3
COULOMB_CONSTANT The value of Coulomb's Constant 8.9875517879 1.3.3
EULER_NUMBER The value of Euler's number 2.7182818285 1.3.3
GRAVITATIONAL_CONSTANT The gravitational constant 6.67408-11 1.7.5
ATOMIC_MASS The atomic mass constant 1.6627 1.7.5
GOLDEN_RATIO The value of the Golden Ratio 1.6180339887498948482 1.7.5
Execution time constants
ZPE_VERSION_MAJOR The major version number of the ZPE instance used to compile the script. Varies 1.3.6
ZPE_VERSION_MINOR The minor version number of the ZPE instance used to compile the script. 1.3.6
ZPE_CLI_VERSION The CLI version number of the ZPE instance used to compile the script. 1.3.6

All constants are compiled are translated to their values at compile time unless they are specified as execution constants. This change came around with version 1.12.6.

Prior to version 1.12.6

From version 1.7.2 to version 1.12.5, all constants were compiled at runtime.

From version 1.7.2 the way constants work was completely rewritten and made them very different from variables in the way they work as they are compiled at compile time into their values. For example:

YASS
$x = PI
        

Since constants can be changed from the configuration file, it is possible to change, say, the value of the PI constant. If this program was compiled and distributed, the value of the PI constant would be set to what the value of PI was when the program was compiled and would not not change to the user's version specified in their configuration file.

Prior to version 1.7.2

Prior to ZPE 1.7.2, constants were accessed using the name of the constant preceded by a # symbol:

YASS
$x = #a
        

Prior to version 1.6.4, the constant was assigned in the same way it is accessed:

YASS
#a = 51
$x = #a
        
Comments
Feedback 👍
Comments are sent via email to me.