Lhogho  0.0.027
Vars

Vars module contains functions for managing variables, commands, functions, and operators.

Structure

Variables are special kind of structures which require two or three atoms to hold their description. The macros DESCR1 and DESCR2 are used to access these additional atoms:

Use IS_VARATOM() macro to check whether the atom is a var atom.

var_structure.png
Structure of var atoms

There are three groups of variables depending on their values. The group code is accessed with the VARTYPE macro:

Primitive variables

Primitive variables are those which are automatically created by Lhogho. For example, such variables are PRINTDEPTHLIMIT, CASEIGNOREDP, LOGOVERSION and others. The macros which access data of primitive variables are:

Use IS_VARIABLE and IS_PRIMITIVE macros to check for primitive variables.

User-defined variables

User-defined variables are those which are defined by user's program code. There are several types of such variables, depending on how they are created.

Compile-time variables

These variables are processed during the compilation of the program. Usually these are variables created with LOCAL and MAKE. The values of such variables are stored in the stack. The macros which access data of compile-time variables are:

Use IS_VARIABLE and IS_NORMAL macros to check for compile-time variables.

Run-time variables

These variables are processed during the execution of the program. Usually these are variables created with LOCAL when the input is an expression. The values of such variables are stored in the DATA field of DESCR1. The macros which access data of run-time variables are:

Use IS_VARIABLE and IS_RUNTIME macros to check for variables that store their values in VALUE.

Global variables

These variables are similar to the run-time variable as long as their values are stored in the DATA field of DESCR1. The macros which access data of global variables are:

Use IS_VARIABLE and IS_GLOBAL macros to check for global variables. Note that globals variable also contains the primitive variables.

Primitive functions

Primitive functions (this includes primitive commands and operators) are defined automatically by Lhogho. There is no any Logo source code corresponding to these functions. The macros which access data of primitive functions are:

All these data are placed in the first descriptor. The second one is NULL. Primitive functions can be checked with IS_PRIMITIVE, IS_FUNCTION, IS_COMMAND macro.

User-defined functions

User-defined functions, commands and operators are defined by Logo source code. They contain these data:

Tags

Tags are recorded as local variables. The tag name becomes the name of the variable, and the tag address becomes value of the variable. Tag variables have their VARTYPE value equal to VAR_TYPE_TAG. The macros which access data of primitive variables are:

Use IS_VARIABLE and IS_TAG macros to check for tags.

Flags

Var atoms have bitmask flags with the following meaning:

There are extended flags (FLAGS_EX_) which are used only in the vars[] definition of the variables. These flags do not exist in the FLAGS field of the var atoms.

-FLAG_EX_PRINTDEPTHLIMIT. This flag is used during the creation of the top-level variable printdepthlimit.

-FLAG_EX_PRINTWIDTHLIMIT. This flag is used during the creation of the top-level variable printwidthlimit.

-FLAG_EX_FULLPRINTP. This flag is used during the creation of the top-level variable fullprintp.

-FLAG_EX_CASEIGNOREDP. This flag is used during the creation of the top-level variable caseignoredp.

Special variables

Lhogho defines several special variables:


[ HOME | INDEX | ATOMS | VARS | REFERENCE ]
Lhogho Developer's Documentation
Tue Feb 7 2012