-
Notifications
You must be signed in to change notification settings - Fork 0
Constants
LangKama allows for the declaration of constants, providing a way to define values that are intended to remain unchanged throughout the execution of a program. This section details the syntax for constant declaration, common errors associated with constants, and how to avoid them.
Constants in LangKama are declared using a syntax similar to variable declaration, but they are intended to hold values that cannot be changed once set.
Constants must be declared with an initial value. The declaration starts with a narrative approach, using a sa7 hear me out
, followed by the constant name, the is
keyword, and the value.
a sa7 hear me out zero is 0.
LangKama includes specific error-handling mechanisms for constants to ensure that their immutable nature is preserved and that declarations are correctly formulated.
Attempting to declare a constant without specifying an initial value results in an error. Constants must always be initialized during declaration.
a sa7 hear me out zero. bs Missing initial value
LangKama prevents the redeclaration of constants with the same name, ensuring each constant is uniquely identified within its scope.
a sa7 hear me out zero is 0.
a sa7 hear me out zero is 0. bs Attempting to duplicate the 'zero' constant
Since constants cannot be changed once declared, attempting to reassign a constant's value results in an error.
a sa7 hear me out one is 1.
one is 2. bs Attempting to reassign the "one" constant
Referencing a constant that has not been declared results in an error. This ensures that all constants are defined before use.
myVar. bs "myVar" has not been declared