HELP IDENTIFIERS                                   John Gibson June 1987

-- Introduction -------------------------------------------------------

POP-11 uses words to name things. Words are stored in a dictionary so
that the system can tell when it reads in a word whether it is one that
has been met before.

Words can be declared as program identifiers (i.e. variables and
constants). Program identifiers have various different forms. These are
described below. The main procedure for finding things out what
properties a word has is -identprops-, explained in HELP *IDENTPROPS.
For more technical details of POP-11 identifiers see REF *IDENT.

         CONTENTS - (Use <ENTER> g to access required sections)

 -- Introduction
 -- PERMANENT and LEXICAL
 -- VARIABLE or CONSTANT
 -- PROTECTED
 -- ASSIGNABLE
 -- PROCEDURE-ONLY
 -- OPERATORS
 -- GLOBAL
 -- MACROS
 -- SYNTAX WORDS
 -- ACTIVE VARIABLES
 -- RELATED DOCUMENTATION

-- PERMANENT and LEXICAL ----------------------------------------------

Identifiers can be:

    PERMANENT    or
    LEXICAL

The basic difference between these is that lexical identifiers can be
referenced only inside the unit of program text inside which they are
declared (i.e. a procedure or a file), and then only while that text is
being compiled, whereas permanent identifiers once declared can be
referred to anywhere and at any time (unless they cancelled at some
point).

When declared as an identifier, the syntactic and other properties
associated with a word are held in an 'identifier record', which becomes
attached to the word: for lexical identifiers, this attachment ceases as
soon as the corresponding unit of program text has finished compiling,
but for permanent identifiers it remains until cancelled. In order to
allow modular program construction, permanent identifiers can also have
different attachments in different "sections".

HELP *VARIABLES, *LEXICAL, *LVARS, *SECTIONS, *LCONSTANT, *CANCEL.

-- VARIABLE or CONSTANT -----------------------------------------------

Identifiers can be:

    variables (multiple assignment)
    constants (single assignment)

The basic difference is that variables can be assigned to many times,
constants can only be assigned to once.

HELP *CONSTANT, *VARIABLES, *ISCONSTANT, CANCEL.

-- PROTECTED ----------------------------------------------------------

Permanent identifiers can be protected.  You aren't normally allowed to
assign to a protected identifier.  In some circumstances it is necessary
to do so, and you will have to unprotect the identifier.

HELP *SYSUNPROTECT, *SYSPROTECT, *ISPROTECTED.

-- ASSIGNABLE ---------------------------------------------------------

Identifiers can be assignable.  You can assign to any (unprotected)
variable and any (unprotected) constant which hasn't yet been
initialised.  To test whether an identifer is assignable use the
procedure "isassignable".

HELP * ISASSIGNABLE, *CONSTANT.

-- PROCEDURE-ONLY -----------------------------------------------------

Identifiers can be procedure-only.  In certain cases, for efficiency or
clarity of code, it is sometimes desirable to say that a given
identifier is only allowed to hold a procedure value.  You can see if an
identifier is typed by using the procedure "identtype". (Note: once an
identifier has been declare as being procedure-only, it can never become
a non-procedure-only identifier without cancelling it first.)

HELP *IDENTTYPE, *CANCEL.

-- OPERATORS ----------------------------------------------------------

Identifiers can be operators.  This means that they can occur between
two other expressions, like the operator "+".  Operators have a
precedence (a number) which is used to disambiguate expressions like
1 + 2 * 3. A precedence with a higher number has a looser binding.  (So
"+" has 5 and "*" has 4 as the precedence.) A negative precedence is
left-associative.  This means that a -- b -- c would be mean (a -- b) --
c rather than a -- (b -- c) There are no such operators built in to the
system. You can get the precedence of an operator, and see that it is an
operator, with the procedure "identprops".  The identprops of an
operator word is a non-zero number, which is the precedence.  Operators
are always procedure-only identifiers.

-- GLOBAL -------------------------------------------------------------

Permanent identifiers can be global.  These identifiers will be imported
down the section tree from the highest point which they are exported to.
To find out if a word is global, use the procedure "isglobal".

HELP *SECTIONS, REF *SECTIONS, HELP *ISGLOBAL.

-- MACROS -------------------------------------------------------------

Identifiers can be macros. Macros are used to write 'shorthand' for
longer expressions.

HELP *MACRO, *DEFINE, *MACROS, *IDENTPROPS.

-- SYNTAX WORDS -------------------------------------------------------

Identifiers can be syntax words.  These define syntactic constructs,
e.g., "IF", "WHILE", "DEFINE", "(", ")". You can define new ones if you
want to extend POP-11 syntax for special purposes. Syntax words can also
be syntax operators.  You can test for syntax words by looking at their
identprops, which will be the word "syntax". The identprops of a syntax
operator will be a word which begins with "syntax" and then has a
number, which is its precedence.

Defining your syntax own: HELP *SYNTAX, REF *POPCOMPILE
Existing POP-11 syntax words: REF * SYNTAX, *POPSYNTAX

-- ACTIVE VARIABLES ---------------------------------------------------

Since POPLOG V13. it has been possible to define 'active' variables.
Active variables allow the storage of multiple values and allow side
effects to be associated with the access or updating of a variable.

HELP *ACTIVE_VARIABLES, *VARIABLES, REF *IDENT.

-- RELATED DOCUMENTATION ----------------------------------------------

For more technical details of words and identifiers:

REF  *WORDS         - details of word records and the dictionary
HELP *WORDS         - on word records and the dictionary
HELP *WORDSWITH     - identifying sets of words in the POP-11 dictionary
                        with shared subwords
HELP *APPDIC        - applying a procedure to words in the dictionary
REF  *IDENT         - describes identifiers and their relation to words
HELP *IDENTPROPS    - procedure which returns some identifier properties

Other useful procedures connected with identifiers:

HELP *FULL_IDENTPROPS - gives full information, uses the following
HELP *ISCONSTANT    - distinguished variables from constants
HELP *ISASSIGNABLE  - if you can to assign it a value
HELP *ISPROTECTED   - if the value is protected
HELP *IDENTTYPE     - identifies typed identifiers
HELP *ISGLOBAL      - spots 'global' permanent identifiers
HELP *ISACTIVE      - tells whether an identifier is active or not

Declaring identifiers in POP-11:

HELP *VARS          - declaring permanent variables
HELP *DLOCAL        - declaring dynamic, local expressions
HELP *CONSTANT      - declaring constants
HELP *LVARS         - declaring lexical variables
HELP *LCONSTANT     - declaring lexical constants
HELP *LEXICAL       - uses of lexical variables

Other related documentation:

HELP *SYNTAX        - defining new syntax words
REF  *POPSYNTAX     - descriptions of POP-11 syntax
HELP *PROGLIST      - introduction to proglist
REF  *PROGLIST      - the stream of input program text items, macros
REF  *POPCOMPILE    - full details on the POP-11 compiler
REF  *VMCODE        - a description of the POPLOG Virtual Machine

--- C.all/help/identifiers ---------------------------------------------
--- Copyright University of Sussex 1987. All rights reserved. ----------
