Ficl Glossary


Standard wordsets

Ficl implements all words in the following Standard wordsets. Follow the links to the glossaries in the standard for descriptions.

Core
Exception
Exception Extensions
File Access
File Access Extension
Locals
Locals Extensions
Memory Allocation
Programming Tools
Search Order
Search Order Extensions

Ficl partially implements the following wordsets

Core Extensions
Floating Point
Floating Point Extensions
Programming Tools Extensions

Ficl extras

Number syntax

You can precede a number with "0x", as in C, and it will be interpreted as a hex value regardless of the value of BASE. Likewise, numbers prefixed with "0d" will be interpreted as decimal values. Example:
decimal 123 . cr
123 
ok> 0x123 . cr
291 
ok> 0x123 x. cr
123 ok> 
Note: (ficl2.05 and later) This behavior is controlled by the prefix parser defined in prefix.c. You can add other prefixes by defining handlers for them in ficl or C.

Ficl extensions to the SEARCH wordset

Ficl implements many of the search order words in terms of two primitives called >SEARCH and SEARCH>. As their names suggest, the search order list is treated as a stack, and these words push and pop it.

The standard does not appear to specify any conditions under which the search order is reset to a sane state. Ficl resets the search order to its default state whenever ABORT happens. This includes stack underflows and overflows. QUIT does not affect the search order. The minimum search order (set by ONLY) is equivalent to

FORTH-WORDLIST 1 SET-ORDER

There is a default maximum of 16 wordlists in the search order. This can be changed by redefining FICL_DEFAULT_VOCS (declared in sysdep.h).

Note: Ficl resets the search order whenever it does ABORT. If you don't like this behavior, just comment out the dictResetSearchOrder() lines in ficlExec().

>search ( wid -- )
Push wid onto the search order. Many of the other search order words are written in terms of the SEARCH> and >SEARCH primitives. This word can be defined in ANS Forth as follows
: >search   >r get-order 1+ r> swap set-order ;
search> ( -- wid )
Pop wid off the search order. Can be coded in ANS Forth as:
: search>  get-order nip 1- set-order ;
ficl-set-current ( wid -- old-wid )
Set wid as compile wordlist, leaving the previous compile wordlist on the stack
ficl-vocabulary ( nBins "name" -- )
Creates a ficl-wordlist with the specified number of hash table bins, binds it to the name, and associates the semantics of vocabulary with it (replaces the top wid in the search order list with its own wid when executed)
ficl-wordlist ( nBins -- wid )
Creates a wordlist with the specified number of hash table bins, and leaves the address of the wordlist on the stack. A ficl-wordlist behaves exactly as a regular wordlist, but it may search faster depending on the number of bins chosen and the number of words it contains at search time. As implemented in ficl, a wordlist is single threaded by default. ficl-named-wordlist takes a name for the wordlist and creates a word that pushes the wid. This is by contrast to VOCABULARY, which also has a name, but replaces the top of the search order with its wid.
forget-wid ( wid -- )
Iterates through the specified wordlist and unlinks all definitions whose xt addresses are greater than or equal to the value of HERE, the dictionary fill pointer.
hide ( -- current-wid-was )
Push the hidden wordlist onto the search order, and set it as the current compile wordlist (unsing ficl-set-current). Leaves the previous compile wordlist ID. I use this word to hide implementation factor words that have low reuse potential so that they don't clutter the default wordlist. To undo the effect of hide, execute previous set-current
hidden ( -- wid )
Wordlist for storing implementation factors of ficl provided words. To see what's in there, try: hide words previous set-current
wid-get-name ( wid -- c-addr u )
Ficl wordlists (2.05 and later) have a name property that can be assigned. This is used by ORDER to list the names of wordlists in the search order.
wid-set-name ( c-addr wid -- )
Ficl wordlists (2.05 and later) have a name property that can be assigned. This is used by ORDER to list the names of wordlists in the search order. The name is assumed to be a \0 terminated string (C style), which conveniently is how Ficl stores word names. See softwords/softcore.fr definition of brand-wordlist
wid-set-super ( wid -- )
Ficl wordlists have a parent wordlist pointer that is not specified in standard Forth. Ficl initializes this pointer to NULL whenever it creates a wordlist, so it ordinarily has no effect. This word sets the parent pointer to the wordlist specified on the top of the stack. Ficl's implementation of SEARCH-WORDLIST will chain backward through the parent link of the wordlist when searching. This simplifies Ficl's object model in that the search order does not need to reflect an object's class hierarchy when searching for a method. It is possible to implement Ficl object syntax in strict ANS Forth, but method finders need to manipulate the search order explicitly.

User variables

user ( -- ) name
Create a user variable with the given name. User variables are virtual machine local. Each VM allocates a fixed amount of storage for them. You can change the maximum number of user variables allowed by defining FICL_USER_CELLS on your compiiler's command line. Default is 16 user cells. User variables behave like VARIABLEs in all other respects (you use @ and ! on them, for example). Example:
user current-class
0 current-class !

Miscellaneous

-roll ( xu xu-1 ... x0 u -- x0 xu-1 ... x1 )
Rotate u+1 items on top of the stack after removing u. Rotation is in the opposite sense to ROLL
-rot ( a b c -- c a b )
Rotate the top three stack entries, moving the top of stack to third place. I like to think of this as 11/2swap because it's good for tucking a single cell value behind a cell-pair (like an object).
.env ( -- )
List all environment variables of the system
.hash ( -- )
List hash table performance statistics of the wordlist that's first in the search order
.ver ( -- )
Display ficl version ID
>name ( xt -- c-addr u )
Convert a word's execution token into the address and length of its name
body> ( a-addr -- xt )
Reverses the effect of CORE word >body (converts a parameter field address to an execution token)
compile-only
Mark the most recently defined word as being executable only while in compile state. Many immediate words have this property.
empty ( -- )
Empty the parameter stack
endif
Synonym for THEN
last-word ( -- xt )
Pushes the xt address of the most recently defined word. This applies to colon definitions, constants, variables, and words that use create. You can print the name of the most recently defined word with
last-word >name type
parse-word ( <spaces>name -- c-addr u )
Skip leading spaces and parse name delimited by a space. c-addr is the address within the input buffer and u is the length of the selected string. If the parse area is empty, the resulting string has a zero length. (From the Standard)
q@ ( addr -- x )
Fetch a 32 bit quantity from the specified address
q! ( x addr -- )
Store a 32 bit quantity to the specified address
w@ ( addr -- x )
Fetch a 16 bit quantity from the specified address
w! ( x addr -- )
Store a 16 bit quantity to the specified address (the low 16 bits of the given value)
x. ( x -- )
Pop and display the value in hex format, regardless of the current value of BASE

Extra words defined in testmain.c (Win32 and POSIX versions)

break ( -- )
Does nothing - just a handy place to set a debugger breakpoint
cd ( "directory-name<newline>" -- )
Executes the Win32 chdir() function, changing the program's logged directory.
clock ( -- now )
Wrapper for the ANSI C clock() function. Returns the number of clock ticks elapsed since process start.
clocks/sec ( -- clocks_per_sec )
Pushes the number of ticks in a second as returned by clock
load ( "filename<newline>" -- )
Opens the Forth source file specified and loads it one line at a time, like INCLUDED (FILE)
pwd ( -- )
Prints the current working directory as set by cd
system ( "command<newline>" -- )
Issues a command to a shell; implemented with the Win32 system() call.
spewhash ( "filename<newline>" -- )
Dumps all threads of the current compilation wordlist to the specified text file. This was useful when I thought there might be some point in attempting to optimize the hash function. I no longer harbor those illusions.

Words defined in FiclWin only

!oreg ( c -- )
Set the value of the simulated LED register as specified (0..255)
@ireg ( -- c )
Gets the value of the simulated switch block (0..255)
!dac ( c -- )
Sets the value of the bargraph control as specified. Valid values range from 0..255
@adc ( -- c )
Fetches the current position of the slider control. Range is 0..255
status" ( "ccc<quote>" -- )
Set the mainframe window's status line to the text specified, up to the first trailing quote character.
ms ( u -- )
Causes the running virtual machine to sleep() for the number of milliseconds specified by the top-of-stack value.