To use this website fully, you first need to accept the use of cookies. By agreeing to the use of cookies you consent to the use of functional cookies. For more information read this page.

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
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
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

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 = ZPE_VERSION_MAJOR
        

If this program was compiled and distributed, the value of the ZPE_VERSION_MAJOR constant would not change to the user's version of ZPE since it was precompiled with that value.

Prior to ZPE 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

There are no comments on this page.

New comment
Reply
Provide feedback on this page
Comments are sent via email to me.