Search Top Index
HELP CONSTANT Aaron Sloman, April 1982 This syntax word can be used in global identifier declarations and procedure definitions. constant x y z; declares X,Y, and Z as constant global identifiers. Each of them can then be assigned to ONCE only. Thereafter use of these variables in procedure definitions will produce slightly more efficient programs than if they were used as ordinary identifiers. A constant identifier cannot be used as a local variable in a procedure definition. Procedure names can also be defined as constant, e.g. define constant foo(); .............. enddefine; Thereafter any attempt to assign to FOO will cause an error, and subsequently compiled procedures which call FOO will do so more efficiently than if an ordinary procedure definition were used. However it will NOT be possible to trace FOO. Procedure identifiers can be declared as a constants before the procedure definitions, thus: constant procedure (foo, proc1, proc2); followed later by the procedure definitions of FOO, PROC1, PROC2. Intervening calls of FOO in other procedure definitions will then be compiled without the procedure type-check, and will therefore be more efficient. In general the syntax for CONSTANT declarations follows the syntax for *VARS. If something has been declared to be a constant it can be redeclared, globally, using a VARS or *DEFINE statement. However, a variable declared as of type *PROCEDURE cannot be redeclared to be an ordinary variable. Moreover, after redefining a constant it may be necessary to recompile previously compiled procedures which use it. If *POPDEFINECONSTANT is true, then all procedures definitions are automatically interpreted as defining the names as constants. Lexical identifiers may be declared as constant using LCONSTANT, either globally within a file, or locally within a procedure. In the latter case the value will be assigned once only, at compile time. Identifiers declared using LCONSTANT, as with LVARS, may be accessed only within the lexical scope of the definition - a file (or compile stream) or a procedure. -- RELARED DOCUMENTATION ---------------------------------------------- HELP *PROCEDURE - on the declaration of procedure names HELP *VARIABLES - range and nature of POP-11 variables HELP *VARS - declaration of dynamically scoped variables HELP *IDENTIFIERS - the nature of identifiers HELP *LEXICAL - lexically scoped variables HELP *LVARS - declaration of lexically scoped variables HELP *IDENTPROPS - accessing information about identifiers For more technical information see: REF * WORDS - the nature of POP-11 words REF * IDENT - the nature of indentifiers REF * VMCODE - for full technical details of the virtual machine --- C.all/help/constant ------------------------------------------------ --- Copyright University of Sussex 1987. All rights reserved. ----------