|6.6.0. Symbolic Constants
header files of C libraries are often filled with large amounts of
#define directives that define numerical macros, flags and other
constants. Interfacing these libraries to Lush requires to turn those
constants into Lisp symbols. Lush contains a mechanism for defining such
constants without filling up the global variable name space and risquing
name clashes. Constants can be defined with the
(defconstant "constant-name" value) directive. Constants can
later be accessed using the @constant-name
macro or the @@constant-name macro.
The @ macro expands into a macro that
evaluates to the value, while @@
directly expands to the value at read time.
See: @ identifier
See: (defconstant identifier
|184.108.40.206. (defconstant identifier val)
Defines a symbolic constant named identifier
and equal to val . Argument
identifier must be a string or a symbol. Argument
val must be a number or a string. These constant values are
not accessible as variables but are accessible using the |@|
|220.127.116.11. @identifier @@identifier
These macro-character expand to a expressions that retrieve the value of
the symbolic constant named identifier
. The @ form causes the retrieval to
occur at macro-expansion time. while the @@
form causes the retrieval to occur at read time. These macros are
particularly useful for using symbolic constants in compiled code.
Argument identifier must be a legal C
- If identifier
has not been defined using defconstant
, the global value of the symbol named identifier
- If the macro-character |@| cannot
read a legal C identifier name, it reads a lisp expression and arranges
for that expression to be evaluated during the macro expansion time.
- The expansion of the @@ form
depends on the execution of the previous expressions, which may cause
discrepancies when loading tokenized files. However, the
@@ is more efficient in interpreted mode since the expansion
occurs in advance of execution.