| Forth | |
|---|---|
| Paradigm | concatenative (stack-based),procedural,reflective |
| Designed by | Charles H. Moore |
| First appeared | 1970; 55 years ago (1970) |
| Typing discipline | Typeless |
| Filename extensions | .fs, .fth, .4th, .f, .forth[citation needed] |
| Website | forth-standard |
| Majorimplementations | |
| SwiftForth (Forth, Inc.) Gforth (GNU Project) VFX Forth (MicroProcessor Engineering) | |
| Influenced | |
| Bitcoin Script,Factor,Joy,RPL,Rebol,STOIC,8th | |
Forth is astack-orientedprogramming language and interactiveintegrated development environment designed byCharles H. "Chuck" Moore and first used by other programmers in 1970. Although not anacronym, the language's name in its early years was often spelled inall capital letters asFORTH. The FORTH-79 and FORTH-83 implementations, which were not written by Moore, becamede facto standards, and an officialtechnical standard of the language was published in 1994 as ANS Forth. A wide range of Forth derivatives existed before and after ANS Forth. Thefree and open-source softwareGforth implementation is actively maintained, as are severalcommercially supported systems.
Forth typically combines a compiler with an integrated command shell, where the user interacts viasubroutines calledwords.[a]
Words can be defined, tested, redefined, and debugged without recompiling or restarting the whole program. All syntactic elements, including variables, operators, and control flow, are defined as words. Astack is used to pass parameters between words, leading to aReverse Polish notation style.
For much of Forth's existence, the standard technique was to compile tothreaded code, which can be interpreted faster thanbytecode. One of the early benefits of Forth was size: an entire development environment—including compiler, editor, and user programs—could fit in memory on an 8-bit or similarly limited system. No longer constrained by space, there are modern implementations that generateoptimizedmachine code like other language compilers.
The relative simplicity of creating a basic Forth system has led to many personal and proprietary variants, such as the custom Forth used to implement the bestselling 1986 video gameStarflight fromElectronic Arts.[3] Forth is used in theOpen Firmwareboot loader, inspaceflight applications[4] such as thePhilae spacecraft,[5][6] and in other embedded systems which involve interaction with hardware.
Beginning in the early 1980s, Moore developed a series of microprocessors for executing compiled Forth-like code directly and experimented with smaller languages based on Forth concepts, including cmForth andcolorForth. Most of these languages were created to support Moore's own projects, such as chip design.
Forth has a niche in astronomical and space applications[7] as well as a history inembedded systems. TheOpen Firmwareboot ROMs used byApple,IBM,Sun, andOLPC XO-1 contain a Forth environment.
Forth has often been used to bring up new hardware. Forth was the firstresident software on the newIntel 8086 chip in 1978, and MacFORTH was the first resident development system for theMacintosh 128K in 1984.[8]
Circa 1982,Atari, Inc. used an elaborate animated demo written in Forth to showcase capabilities of theAtari 8-bit computers in department stores.[9]Electronic Arts published multiple video games in the 1980s that were written in Forth, includingWorms? (1983),[10]Adventure Construction Set (1984),[11]Amnesia (1986),[12]Starflight (1986),[3] andLords of Conquest (1986). Robot coding gameChipWits (1984) was developed in MacFORTH for theMacintosh 128K,[13] while theCommodore 64 port was written with SuperForth 64.[14]
Ashton-Tate's RapidFile (1986), a flat-file database program, and VP-Planner[15] fromPaperback Software International (1983), a spreadsheet program competing withLotus 1-2-3, were written in Forth.
TheCanon Cat (1987) uses Forth for its system programming.
Rockwell produced single-chip microcomputers with resident Forth kernels: the R65F11 and R65F12.
ASYST was a Forth expansion for measuring and controlling on PCs.[16]
Forth evolved fromCharles H. Moore's personal programming system, which had been in continuous development since 1968.[8][17] Forth was first exposed to other programmers in the early 1970s, starting withElizabeth Rather at the United StatesNational Radio Astronomy Observatory (NRAO).[8] After their work at NRAO, Charles Moore and Elizabeth Rather formed FORTH, Inc. in 1973, refining and porting Forth systems to dozens of other platforms in the next decade.
Moore saw Forth as a successor to compile-link-gothird-generation programming languages, or software for "fourth generation" hardware. He recalls how the name was coined:[18]
AtMohasco ["in the late 1960s"] I also worked directly on anIBM 1130 interfaced with anIBM 2250 graphics display. The 1130 was a very important computer: it had the first cartridge disk, as well as a card reader, a card punch (as backup for the disk), and a console typewriter. The 1130 let the programmer, for the first time, totally control the computer interactively.
FORTH first appeared as an entity on that 1130. It was called F-O-R-T-H, a five-letter abbreviation of FOURTH, standing for fourth-generation computer language. That was the day, you may remember, of third-generation computers and I was going to leapfrog. But because FORTH ran on the 1130 (which permitted only five-character identifiers), the name was shortened.
FORTH, Inc.'s microFORTH was developed for theIntel 8080,Motorola 6800,Zilog Z80, andRCA 1802 microprocessors, starting in 1976. MicroFORTH was later used by hobbyists to generate Forth systems for other architectures, such as the6502 in 1978. The Forth Interest Group was formed in 1978.[19] It promoted and distributed its own version of the language, FIG-Forth, for most makes of home computer.
Forth was popular in the early 1980s,[20] because it was well suited to the limited memory ofmicrocomputers. The ease of implementing the language led to many implementations.[21] TheJupiter ACE home computer has Forth in itsROM-resident operating system. Insoft GraFORTH is a version of Forth with graphics extensions for the Apple II.[22]
Common practice was codified in the de facto standards FORTH-79[23] and FORTH-83[24] in the years 1979 and 1983, respectively. These standards were unified byANSI in 1994, commonly referred to as ANS Forth.[25][26]
As of 2018, the source for the original 1130 version of FORTH has been recovered, and is now being updated to run on a restored or emulated 1130 system.[27]
Forth emphasizes the use of small, simple functions calledwords. Words for bigger tasks call upon many smaller words that each accomplish a distinct sub-task. A large Forth program is a hierarchy of words. These words, being distinct modules that communicate implicitly via a stack mechanism, can be prototyped, built and tested independently. The highest level of Forth code may resemble an English-language description of the application. Forth has been called ameta-application language: a language that can be used to createproblem-oriented languages.[28]
Forth relies on implicit use of adata stack andreverse Polish notation which is commonly used in calculators fromHewlett-Packard. In RPN, the operator is placed after its operands, as opposed to the more commoninfix notation where the operator is placed between its operands. Postfix notation makes the language easier to parse and extend; Forth's flexibility makes a staticBNF grammar inappropriate, and it does not have a monolithic compiler. Extending the compiler only requires writing a new word, instead of modifying a grammar and changing the underlying implementation.
Using RPN, one can compute the value of the arithmetic expression (25 × 10) + 50 in the following way:
2510*50+CR.300ok

First the numbers 25 and 10 are put on the stack.

The word* takes the top two numbers from the stack, multiplies them, and puts the product back on the stack.

Then the number 50 is placed on the stack.

The word+ takes the top two numbers from the stack, adds them, and puts the sum back on the stack.CR (carriage return) starts the output on a new line. Finally,. prints the result. As everything has completed successfully, the Forth system printsOK.[29]
Even Forth's structural features are stack-based. For example:
:FLOOR5( n -- n' )DUP6<IFDROP5ELSE1-THEN;
The colon indicates the beginning of a new definition, in this case a new word (again,word is the term used for a subroutine) calledFLOOR5. The text in parentheses is a comment, advising that this word expects a number on the stack and will return a possibly changed number (on the stack).
The subroutine uses the following commands:DUP duplicates the number on the stack;6 pushes a 6 on top of the stack;< compares the top two numbers on the stack (6 and theDUPed input), and replaces them with a true-or-false value;IF takes a true-or-false value and chooses to execute commands immediately after it or to skip to theELSE;DROP discards the value on the stack;5 pushes a 5 on top of the stack; andTHEN ends the conditional.
TheFLOOR5 word is equivalent to this function written in theC programming language using theconditional operator '?:'
intfloor5(intv){return(v<6)?5:(v-1);}
This function is written more succinctly as:
:FLOOR5( n -- n' )1-5MAX;
This can be run as follows:
1FLOOR5CR.5ok8FLOOR5CR.7ok
First a number (1 or 8) is pushed onto the stack,FLOOR5 is called, which pops the number again and pushes the result.CR moves the output to a new line (again, this is only here for readability). Finally, a call to. pops the result and prints.
Forth'sgrammar has no official specification. Instead, it is defined by a simple algorithm. The interpreter reads a line of input from the user input device, which is then parsed for a word using spaces as adelimiter; some systems recognise additionalwhitespace characters. When the interpreter finds a word, it looks the word up in thedictionary. If the word is found, the interpreter executes the code associated with the word, and then returns to parse the rest of the input stream. If the word isn't found, the word is assumed to be a number and an attempt is made to convert it into a number and push it on the stack; if successful, the interpreter continues parsing the input stream. Otherwise, if both the lookup and the number conversion fail, the interpreter prints the word followed by an error message indicating that the word is not recognised, flushes the input stream, and waits for new user input.[30]
The definition of a new word is started with the word: (colon) and ends with the word; (semi-colon). For example,
:XDUP1+..;
will compile the wordX, and makes the name findable in the dictionary. When executed by typing10 X at the console this will print11 10.[31]
Most Forth systems include anassembler to write words using the processor's facilities. Forth assemblers often use a reverse Polish syntax in which the parameters of an instruction precede the instruction. A typical reverse Polish assembler prepares the operands on the stack and the mnemonic copies the whole instruction into memory as the last step. A Forth assembler is by nature a macro assembler, so that it is easy to define an alias for registers according to their role in the Forth system: e.g. "dsp" for the register used as the data stack pointer.[32]
Most Forth systems run under a host operating system such asMicrosoft Windows,Linux or a version ofUnix and use the host operating system's file system for source and data files; the ANSI Forth Standard describes the words used for I/O. All modern Forth systems use normal text files for source, even if they are embedded. An embedded system with a resident compiler gets its source via a serial line.
Classic Forth systems traditionally use neitheroperating system norfile system. Instead of storing code in files, source code is stored in disk blocks written to physical disk addresses. The wordBLOCK is employed to translate the number of a 1K-sized block of disk space into the address of a buffer containing the data, which is managed automatically by the Forth system. Block use has become rare since the mid-1990s. In a hosted system those blocks too are allocated in a normal file in any case.
Multitasking, most commonlycooperativeround-robin scheduling, is normally available (although multitasking words and support are not covered by the ANSI Forth Standard). The wordPAUSE is used to save the current task's execution context, to locate the next task, and restore its execution context. Each task has its own stacks, private copies of some control variables and a scratch area. Swapping tasks is simple and efficient; as a result, Forth multitaskers are available even on very simplemicrocontrollers, such as theIntel 8051,Atmel AVR, andTI MSP430.[33]
Other non-standard facilities include a mechanism for issuingcalls to the host OS orwindowing systems, and many provide extensions that employ the scheduling provided by the operating system. Typically they have a larger and different set of words from the stand-alone Forth'sPAUSE word for task creation, suspension, destruction and modification of priority.
A full-featured Forth system with all source code will compile itself, a technique commonly called meta-compilation orself-hosting, by Forth programmers (although the term doesn't exactly matchmeta-compilation as it is normally defined). The usual method is to redefine the handful of words that place compiled bits into memory. The compiler's words use specially named versions of fetch and store that can be redirected to a buffer area in memory. The buffer area simulates or accesses a memory area beginning at a different address than the code buffer. Such compilers define words to access both the target computer's memory, and the host (compiling) computer's memory.[34]
After the fetch and store operations are redefined for the code space, the compiler, assembler, etc. are recompiled using the new definitions of fetch and store. This effectively reuses all the code of the compiler and interpreter. Then, the Forth system's code is compiled, but this version is stored in the buffer. The buffer in memory is written to disk, and ways are provided to load it temporarily into memory for testing. When the new version appears to work, it is written over the previous version.
Numerous variations of such compilers exist for different environments. Forembedded systems, the code may instead be written to another computer, a technique known ascross compilation, over a serial port or even a singleTTL bit, while keeping the word names and other non-executing parts of the dictionary in the original compiling computer. The minimum definitions for such a Forth compiler are the words that fetch and store a byte, and the word that commands a Forth word to be executed. Often the most time-consuming part of writing a remote port is constructing the initial program to implement fetch, store and execute, but many modern microprocessors have integrated debugging features (such as theMotorola CPU32) that eliminate this task.[35]
The basic data structure of Forth is the "dictionary" which maps "words" to executable code or named data structures. The dictionary is laid out in memory as a tree oflinked lists with the links proceeding from the latest (most recently) defined word to the oldest, until asentinel value, usually a NULL pointer, is found. A context switch causes a list search to start at a different leaf. A linked list search continues as the branch merges into the main trunk leading eventually back to the sentinel, the root.There can be several dictionaries. In rare cases such as meta-compilation a dictionary might be isolated and stand-alone.The effect resembles that of nesting namespaces and can overload keywords depending on the context.
A defined word generally consists ofhead andbody with the head consisting of thename field (NF) and thelink field (LF), and body consisting of thecode field (CF) and theparameter field (PF).
Head and body of a dictionary entry are treated separately because they may not be contiguous. For example, when a Forth program is recompiled for a new platform, the head may remain on the compiling computer, while the body goes to the new platform. In some environments (such asembedded systems) the heads occupy memory unnecessarily. However, some cross-compilers may put heads in the target if the target itself is expected to support an interactive Forth.[36]
The exact format of a dictionary entry is not prescribed, and implementations vary.
The compiler itself is not a monolithic program. It consists of Forth words visible to the system, and usable by a programmer. This allows a programmer to change the compiler's words for special purposes. Compilation in traditional Forth systems is straightforward and does not involve building and optimizing an abstract representation of the code. (Some newer Forth compilers use more elaborate compilation methods, as common in other languages.)
The "compile time" flag in the name field is set for words with "compile time" behavior. Most simple words execute the same code whether they are typed on a command line, or embedded in code. When compiling these, the compiler simply places code or a threaded pointer to the word.[31]
The classic examples of compile-time words are thecontrol structures such asIF andWHILE. Almost all of Forth's control structures and almost all of its compiler are implemented as compile-time words. Apart from some rarely usedcontrol flow words only found in a few implementations, such as the conditional return word?EXIT used in Ulrich Hoffmann's preForth, all of Forth'scontrol flow words are executed during compilation to compile various combinations of primitive words along with their branch addresses.[1][2]
For instance,IF andWHILE, and the words that match with those, set upBRANCH (unconditional branch) and?BRANCH (pop a value off the stack, and branch if it is false). Counted loopcontrol flow words work similarly but set up combinations of primitive words that work with a counter, and so on. During compilation, the data stack is used to support control structure balancing, nesting, and back-patching of branch addresses. The snippet:
...DUP6<IFDROP5ELSE1-THEN...
would often be compiled to the following sequence inside a definition:
...DUPLIT6<?BRANCH5DROPLIT5BRANCH3LIT1-...
The numbers afterBRANCH represent relative jump addresses.LIT is the primitive word for pushing a "literal" number onto the data stack. (Faster, shorter code would be compiled using pointers to constants instead ofLIT and embedded data, if any of the numbers involved have been separately defined as constants. There would be similar changes if yet other words were used instead of constants, and so on.)
The word: (colon) parses a name as a parameter, creates a dictionary entry (acolon definition) and enters compilation state. The interpreter continues to read space-delimited words from the user input device. If a word is found, the interpreter executes thecompilation semantics associated with the word, instead of theinterpretation semantics. The default compilation semantics of a word are to append its interpretation semantics to the current definition.[31]
The word; (semi-colon) finishes the current definition and returns to interpretation state. It is an example of a word whose compilation semantics differ from the default. The interpretation semantics of; (semi-colon), most control flow words, and several other words are undefined in ANS Forth, meaning that they must only be used inside of definitions and not on the interactive command line.[31]
The interpreter state can be changed manually with the words[ (left-bracket) and] (right-bracket) which enter interpretation state or compilation state, respectively. These words can be used with the wordLITERAL to calculate a value during a compilation and to insert the calculated value into the current colon definition.LITERAL has the compilation semantics to take an object from the data stack and to append semantics to the current colon definition to place that object on the data stack.
In ANS Forth, the current state of the interpreter can be read from theflagSTATE which contains the value true when in compilation state and false otherwise. This allows the implementation of so-calledstate-smart words with behavior that changes according to the current state of the interpreter.
The wordIMMEDIATE marks the most recent colon definition as animmediate word, effectively replacing its compilation semantics with its interpretation semantics.[37] Immediate words are normally executed during compilation, not compiled, but this can be overridden by the programmer in either state.; is an example of an immediate word. In ANS Forth, the wordPOSTPONE takes a name as a parameter and appends the compilation semantics of the named word to the current definition even if the word was marked immediate. Forth-83 defined separate wordsCOMPILE and[COMPILE] to force the compilation of non-immediate and immediate words, respectively.
Instead of reserving space for an Immediate flag in every definition, some implementations of Forth use an Immediates Dictionary which is checked first when in compile mode.
In ANS Forth, unnamed words can be defined with the word:NONAME which compiles the following words up to the next; (semi-colon) and leaves anexecution token on the data stack. The execution token provides an opaque handle for the compiled semantics, similar to thefunction pointers of theC programming language.
Execution tokens can be stored in variables. The wordEXECUTE takes an execution token from the data stack and performs the associated semantics. The wordCOMPILE, (compile-comma) takes an execution token from the data stack and appends the associated semantics to the current definition.
The word' (tick) takes the name of a word as a parameter and returns the execution token associated with that word on the data stack. In interpretation state,' RANDOM-WORD EXECUTE is equivalent toRANDOM-WORD.[38]
The words: (colon),POSTPONE,' (tick) are examples ofparsing words that take their arguments from the user input device instead of the data stack. Another example is the word( (paren) which reads and ignores the following words up to and including the next right parenthesis and is used to place comments in a colon definition. Similarly, the word\ (backslash) is used for comments that continue to the end of the current line. To be parsed correctly,( (paren) and\ (backslash) must be separated by whitespace from the following comment text.
In most Forth systems, the body of a code definition consists of eithermachine language, or some form ofthreaded code. The original Forth which follows the informal FIG standard (Forth Interest Group), is a TIL (Threaded Interpretive Language). This is also called indirect-threaded code, but direct-threaded and subroutine threaded Forths have also become popular in modern times. The fastest modern Forths, such as SwiftForth, VFX Forth, and iForth, compile Forth to native machine code.
When a word is a variable or other data object, the CF points to the runtime code associated with the defining word that created it. A defining word has a characteristic "defining behavior" (creating a dictionary entry plus possibly allocating and initializing data space) and also specifies the behavior of an instance of the class of words constructed by this defining word. Examples include:
VARIABLEVARIABLE returns its address on the stack.CONSTANTCONSTANT). Instance behavior returns the value.CREATEForth also provides a facility by which a programmer can define new application-specific defining words, specifying both a custom defining behavior and instance behavior. Some examples include circular buffers, named bits on an I/O port, and automatically indexed arrays.
Data objects defined by these and similar words are global in scope. The function provided by local variables in other languages is provided by the data stack in Forth (although Forth also has real local variables). Forth programming style uses very few named data objects compared with other languages; typically such data objects are used to contain data which is used by a number of words or tasks (in a multitasked implementation).[39]
Forth does not enforce consistency ofdata type usage; it is the programmer's responsibility to use appropriate operators to fetch and store values or perform other operations on data.
:HELLO( -- )CR."Hello, World!";
HELLO <cr>Hello, World!
The wordCR (Carriage Return) causes the output followingCR to be displayed on a new line. The parsing word." (dot-quote) reads a double-quote delimited string and appends code to the current definition so that the parsed string will be displayed upon execution. The space character separating the word." from the stringHello, World! is not included as part of the string. It is needed so that the parser recognizes." as a Forth word.
A standard Forth system is also an interpreter, and the same output can be obtained by typing the following code fragment into the Forth console:
CR.( Hello, World!)
.( (dot-paren) is an immediate word that parses a parenthesis-delimited string and displays it. As with the word." the space character separating.( fromHello, World! is not part of the string.
The wordCR comes before the text to print. By convention, the Forth interpreter does not start output on a new line. Also by convention, the interpreter waits for input at the end of the previous line, after anok prompt. There is no implied "flush-buffer" action in Forth'sCR, as sometimes is in other programming languages.
Here is the definition of a wordEMIT-Q which when executed emits the single characterQ:
:EMIT-Q81( the ASCII value for the character 'Q' )EMIT;
This definition was written to use theASCII value of theQ character (81) directly. The text between the parentheses is a comment and is ignored by the compiler. The wordEMIT takes a value from the data stack and displays the corresponding character.
The following redefinition ofEMIT-Q uses the words[ (left-bracket),] (right-bracket),CHAR andLITERAL to temporarily switch to interpreter state, calculate the ASCII value of theQ character, return to compilation state and append the calculated value to the current colon definition:
:EMIT-Q[CHARQ]LITERALEMIT;
The parsing wordCHAR takes a space-delimited word as parameter and places the value of its first character on the data stack. The word[CHAR] is an immediate version ofCHAR. Using[CHAR], the example definition forEMIT-Q could be rewritten like this:
:EMIT-Q[CHAR]QEMIT;\ Emit the single character 'Q'
This definition used\ (backslash) for the describing comment.
BothCHAR and[CHAR] are predefined in ANS Forth. UsingIMMEDIATE andPOSTPONE,[CHAR] could have been defined like this:
:[CHAR]CHARPOSTPONELITERAL;IMMEDIATE
In 1987,Ron Rivest developed theRC4 cipher-system for RSA Data Security, Inc. Its description follows:
We have an array of 256 bytes, all different. Every time the array is used it changes by swapping two bytes. The swaps are controlled by countersi andj, each initially 0. To get a newi, add 1. To get a newj, add the array byte at the newi. Exchange the array bytes ati andj. The code is the array byte at the sum of the array bytes ati andj. This is XORed with a byte of the plaintext to encrypt, or the ciphertext to decrypt. The array is initialized by first setting it to 0 through 255. Then step through it usingi andj, getting the newj by adding to it the array byte ati and a key byte, and swapping the array bytes ati andj. Finally,i andj are set to 0. All additions are modulo 256.
The following Standard Forth version uses Core and Core Extension words only.
0valueii0valuejj0valueKeyAddr0valueKeyLencreateSArray256allot\ state array of 256 bytes:KeyArrayKeyLenmodKeyAddr;:get_byte+c@;:set_byte+c!;:as_byte255and;:reset_ij0TOii0TOjj;:i_update1+as_byteTOii;:j_updateiiSArrayget_byte+as_byteTOjj;:swap_s_ijjjSArrayget_byteiiSArrayget_bytejjSArrayset_byteiiSArrayset_byte;:rc4_init( KeyAddr KeyLen -- )256minTOKeyLenTOKeyAddr2560DOiiSArrayset_byteLOOPreset_ijBEGINiiKeyArrayget_bytejj+j_updateswap_s_ijii255<WHILEiii_updateREPEATreset_ij;:rc4_byteiii_updatejjj_updateswap_s_ijiiSArrayget_bytejjSArrayget_byte+as_byteSArrayget_bytexor;
This is one way to test the code:
hexcreateAKey61c,8Ac,63c,D2c,FBc,:testcr0DOrc4_byte.LOOPcr;AKey5rc4_init2CF94CEEDC5test\ output should be: F1 38 29 C9 DE
A processor designed to support a specific programming language is called a language "engine".[40]
Forth engines are hardware platforms specifically designed to support developing and running programs written in Forth. (Likewise,Lisp machines were specifically designed to support developing and running programs written in Lisp, thePascal MicroEngine was specifically designed to support developing and running programs written in Pascal, etc.).
The first commercially available single-chip Forth engine was the Rockwell R65F11,[40]a chip that includes a Forth kernel in ROM,an enhanced 6502, SRAM, and various interface circuits that previously required peripheral chips.[40][41][42][43][44]
Many other commercial CPUs (Harris RTX-2000, Novix NC4016, F21, MARC4, KimKlone, etc.) and manyhomebrew CPUs (My4TH, J1, H2, Mark 1 FORTH Computer, etc.) are specifically designed to run Forth. Typically they implement common Forth primitives such as the "Forth NEXT" as single instructions.
Because Forth is simple to implement and has no standard reference implementation, there are numerous versions of the language. In addition to supporting the standard varieties of desktop computer systems (POSIX,Microsoft Windows,macOS), many of these Forth systems also target a variety ofembedded systems. Listed here are some of the systems which conform to the 1994 ANS Forth standard.
To summarize, there are three kinds of variables: System variables contain values used by the entire Forth system. User variables contain values that are unique for each task, even though the definitions can be used by all tasks in the system. Regular variables can be accessible either system-wide or within a single task only, depending upon whether they are defined withinOPERATOR or within a private task.