7.10.5 Ignored value definitions

Prev Up Next Page 222 of 800 Search internet

If a page value-defines a string, a page symbol, or a construct from another page then the value definition will enter the codex but is otherwise ignored. In particular, value definitions cannot change the value of strings and page symbols which already have values. Neither can a page change the value of a construct defined by some other page.

As a special case, however, if a page value-defines its own page symbol, then the definition is compiled and enters the code hook of the page. The value of the page symbol is unaffected, but one can look up the compiled version of the value definition in the code hook of the page.

As an example, the base page contains a (trivial) value definition of the page symbol 'base':

define value of base as 2 + 3 end define

For that reason, the value of

base [[ base [[ 0 ]] ]] [[ !"code" ]] [[ 0 ]] untag

is five. Constants (constructs of arity zero) that end up in the code hook are only computed first time they are used. Thus, a value definition of the page symbol can be used for computations which are lengthy and whose result has to be used many times.

If this feature is used for real, then the feature has to be shared among everyone who needs it. For that reason, it is suggested to define the value of the page symbol as a two-dimensional array (an array of arrays) A and to use A[r][i] for individual uses where r and i are the reference and index of some construct. If you need this feature, define a construct and use the reference and index of that construct. Or set r to zero and use some string for i. By convention, don't use a reserved string in the latter case (one which contains nothing but small letters a-z and space characters) since such strings are reserved for future extensions of Logiweb.

Prev Up Next Page 222 of 800 Search logiweb.eu

Copyright © 2010 Klaus Grue, GRD-2010-01-05