VARIABLE

Материал из ПМК вики
Перейти к навигации Перейти к поиску

VARIABLE — стандартное слово Каллисто.

Определить следующее слово как переменную с начальным значением нуль.


VARIABLE в стандарте ANS Forth

6.1.2410   VARIABLE                                                        CORE
           ( "<spaces>name" -- )
           Пропускает ведущие разделители пробелы. Выделяет name, ограниченное 
           пробелом. Создает определение для name с семантикой выполнения, 
           определенной ниже. Резервирует одну ячейку области данных в 
           выровненном адресе.
           name объявляется как "variable".
       name Выполнение: ( -- a-addr )
           a-addr - адрес зарезервированной ячейки. Программа ответственна за 
           инициализацию и содержание зарезервированной ячейки.
       См.: 3.4.1 Синтаксический анализ.
A.6.1.2410   VARIABLE
Типичное использование:
       ... VARIABLE XYZ ...


VARIABLE в предыдущем стандарте Forth-83 (англ.)

     VARIABLE     --                            M,79
          A defining word executed in the form:
                  VARIABLE <name>
          A dictionary entry for <name> is created and two bytes are
          ALLOTted in its parameter field.  This parameter field is to
          be used for contents of the variable.  The application is
          responsible for initializing the contents of the variable
          which it creates.  When <name> is later executed, the
          address of its parameter field is placed on the stack.


VARIABLE в стандарте Forth-79 (англ.)

VARIABLE                                     227
    A defining word executed in the form:
         VARIABLE  <name>
    to  create a dictionary entry for <name> and allot  two  bytes
    for  storage  in the parameter field.   The  application  must
    initialize  the stored value.   When <name> is later executed,
    it will place the storage address on the stack.


VARIABLE в fig-FORTH Release 1 glossary, май 1979 (англ.)

VARIABLE                                     E,LU
       A defining word used in the form:
                         n VARIABLE cccc
       When VARIABLE is executed, it creates the definition cccc with its
       parameter field initialized to n. When cccc is later executed, the
       address of its parameter field (containing n) is left on the stack,
       so that a fetch or store may access this location.


История

Начиная с Форта-79, определение целочисленной переменной VARIABLE не требует задания начального значения и не меняет стек. Каллисто и большинство версий Форта записывают в новую переменную ноль, но переносимые программы не должны на это полагаться.

Ссылки


  У этой статьи нет иллюстраций. Вы можете помочь проекту, добавив их.


  Это заготовка статьи. Вы можете помочь проекту, дополнив её.