Search                        Top                                  Index
HELP WORDS                                    Updated A.Sloman July 1986

A word in Poplog is a structure representing a string of characters,
which is normally stored in the dictionary. See HELP * DICTIONARY.

The syntax for forming words in POP-11 is described in detail in
REF * ITEMISE, and illustrated below.

The role of words as data-structures, and procedures for operating
on words and the dictionary are described in REF * WORDS.


-- THE RULES FOR WORD FORMATION IN POP-11 ---------------------------

Words can be explicitly constructed using the procedure *CONSPROC
or implicitly constructed simply by being included in program text.

In program text they can be unquoted, e.g.

    cat -> dog;

or quoted, using the word quote symbol '"', e.g.

    "cat" -> valof("dog");

Inside list and vector expressions words are treated as quoted, e.g.

    [a list of five words {and a vector of words} ]

though they can be "un-quoted" by means of the "up-arrow" symbol "^"
or percent symbol "%". See TEACH * ARROW, TEACH * PERCENT.

In POP-11 there are restrictions on the sequences of characters that
can form implicitly constructed words whether quoted or unquoted.
The restrictions depend on the distinction of characters into different
types, some of which cannot combine with other characters to form a
word, e.g. ".", ";", and bracket symbols, while others can. But not
all combinations are allowed. Using word quote brackets it is possible
to form a quoted word containing arbitrary characters by enclosing them
in string quotes inside the word quotes, thus

    "'a long word with 9870&^%&^% arbitrary ":":$#@$aff characters'"

The restrictions in other contexts are briefly illustrated below. For
full details see REF *ITEMISE.


Try typing the following. Some of them will generate errors:

    list1 =>
    1list =>
    list" =>

POP-11 combines a letter followed by a series of letters and numbers
into a single word; but if you start with a number, then as soon as a
non-number is reached (e.g. the "l" in "1list") it assumes that it
should insert a break, i.e. the text is separated into a number followed
by a word. Similarly it normally breaks the word if a non-alphanumeric
character is reached.

By typing things is lists and printing them out shows how the "itemiser"
breaks things up:

    [list1] =>
    ** [list1]      ;;; one item

    [1list] =>
    ** [1 list]     ;;; two items

    [list"] =>
    ** [list "]     ;;; two items

You can also make a word out of certain non-alpha-numeric characters,
called "SIGN" characters:

    [+*+*+] =>
    ** [+*+*+]      ;;; one item

    [**+  ++*] =>
    ** [**+ ++*]    ;;; two items

    [**+abc] =>
    ** [**+ abc]    ;;; two items

    [abc+++] =>
    ** [abc +++]    ;;; two items

Sign characters are:

 ! # $ & = - ~ ^ | \ @ + * : < > ? /

 (Later `\` may default to an 'alphabeticiser' character).

Some characters which will not join up with others to make a word:

    " % ( ) ' ` { [ } ] ; , .

because they play a special role in the syntax of POP-11. (See
HELP * SYSWORDS)

    ["""] =>
    ** [" " "]      ;;; three items

    [(())] =>
    ** [( ( ) )]    ;;; four items

    [{}] =>
    ** [{}]         ;;; Read as a list containing an empty vector

A sequence of characters made of "sign" characters and letters will be
broken at the point where the two sorts of characters meet, unless they
are joined by an underscore symbol "_", e.g.

    fast_++
    ++_lists_++

The underscore can also be used to join characters of the same type, e.g.

    my_favourite_procedure
    ++_!!_**

You need to know these rules if you wish to declare variables, or create
words using the word quote " .  The following will cause errors:

    "23list" =>
    "aa++++" =>

But not
    "'23list'" =>
    "'aa++++'" =>

If a number precedes a letter in a VARS declaration it is taken to
indicate an operator precedence for an infix operation (See HELP * INFIX)
    vars 2list;

is equivalent to
    vars 2 list;

and declares list as an operator of precedence 2!

Error messages can result from attempting to combine characters of
inappropriate types.

HELP * ALPHABETICISER explains how to convert the character `\` to an
alphabeticiser so that any character it precedes is treated as an
alphabetic character. HELP * ITEM_CHARTYPE indicates more generally how
the itemiser rules can be changed, e.g. if you are using POP-11 to
define a new language.


-- RELATED DOCUMENTATION FILES ----------------------------------------

*ALPHABETICISER - see above
*APPDIC     - applies a procedure to each word in the POP-11 dictionary
*CONSTANT   - use of constant identifiers
*CONSWORD   - creates a word from a string
*COUNTITEM  - counts the number of text items in a file
*DICTIONARY - describes the dictionary in which words are stored
*EXPLODE    - puts all the parts of a data structure on the stack
*GENSYM     - systematically creates new words
*IDENTPROPS - returns the syntactic type of a word
*ITEM_CHARTYPE - accessing and updating itemiser type of characters
*ISWORD     - recogniser procedure for words
*MACRO      - on declaring words as macro-names and non-macro-names
*NONMAC     - allows a macro to be mentioned without being applied
*NONOP      - allows an operation to be mentioned without being applied
*PACKITEM   - creates an integer or word out of a list of characters
*SUBSCRW    - accesses an individual character in a word
*SUBWORD    - creates a smaller 'subword' from a word
*SYSCANCEL  - removes any identifier currently associated with a word
*SYSCANCELWORD - removes a word from the dictionary
*CANCEL     - macro simplifying use of SYSCANCEL
*UNDEF      - on objects of type UNDEF
*UNDEFWORD  - returns word in UNDEF record
*UNPACKITEM - splits a word or integer into a list of words or integers
*VALOF      - accesses or updates the value of a word as an identifier
*VARS       - use and declaration of dynamically scoped variables
*LVARS      - use and declaration of lexically scoped variables
*WORDQUOTE  - on the use of the wordquote "
*WORDSWITH  - lists dictionary words containing a specified substring

See also REF *ITEMISE for details of itemising in POP-11 and REF * WORDS
for system details concerning the representation of words.

--- C.all/help/words
--- Copyright University of Sussex 1988. All rights reserved. ----------