2.3.3 Module constants
A module constant is much like a module variable, except that it is an error to assign a different value to a constant. Although you cannot assign a different value to a constant, you may be able to change the elements of the value, such as assigning a different value to an element of an array.
You use define constant to define a module constant, in the same way that you use define variable to define a variable. You must initialize the value of the constant, and you cannot change that value throughout the execution of a Dylan program. Here is an example:
? define constant $pi = 3.14159;
|
Convention: Module constant names start with the dollar sign, |
Both module variables and module constants are accessible within a module.
(See Section 13.2, page 189, for information about modules.) Dylan also offers variables that are accessible within a smaller area, called local variables. There is no concept of a local constant; all constants are module constants. Therefore, throughout the rest of this book, we use the word constant as shorthand for module constant.




