home: hub: 9ficl

ref: 7393a9a5e8453bbc7c8b767a6af41b463a9ca34a
dir: /doc/ficl_gloss.html/

View raw version
<!DOCTYPE html PUBLIC "-//w3c//dtd html 4.0 transitional//en">
<HTML>
  <HEAD>
    <LINK media="screen" href="ficlstyle.css" type="text/css" rel="stylesheet">
<STYLE type="text/css">
    DT  {
      font-family: courier;
    }
</STYLE>
    <LINK rel="SHORTCUT ICON" href="ficl.ico">
    <TITLE>
      Ficl Glossary
    </TITLE>
  </HEAD>
  <BODY>
    <H1>
      <B>Ficl Glossary</B>
    </H1>
<SCRIPT language="javascript" src="ficlheader.js" type="text/javascript">
</SCRIPT>
    <DIV style="width:675px">
      <HR>
	  <h2>Standard wordsets
	  </h2>
	  <p>
	  Ficl implements all words in the following Standard wordsets. Follow the links to the glossaries in the standard for descriptions.
</P>
<DL>
<dt><a href="http://ficl.sourceforge.net/dpans/dpans6.htm#6.1">Core</a></dt>
<dt><a href="http://ficl.sourceforge.net/dpans/dpans9.htm#9.6.1">Exception</a></dt>
<dt><a href="http://ficl.sourceforge.net/dpans/dpans9.htm#9.6.2">Exception Extensions</a></dt>
<dt><a href="http://ficl.sourceforge.net/dpans/dpans11.htm#11.6.1">File Access</a></dt>
<dt><a href="http://ficl.sourceforge.net/dpans/dpans11.htm#11.6.2">File Access Extension</a></dt>
<dt><a href="http://ficl.sourceforge.net/dpans/dpans13.htm#13.6.1">Locals</a></dt>
<dt><a href="http://ficl.sourceforge.net/dpans/dpans13.htm#13.6.2">Locals Extensions</a></dt>
<dt><a href="http://ficl.sourceforge.net/dpans/dpans14.htm#14.6.1">Memory Allocation</a></dt>
<dt><a href="http://ficl.sourceforge.net/dpans/dpans15.htm#15.6.1">Programming Tools</a></dt>
<dt><a href="http://ficl.sourceforge.net/dpans/dpans16.htm#16.6.1">Search Order</a></dt>
<dt><a href="http://ficl.sourceforge.net/dpans/dpans16.htm#16.6.2">Search Order Extensions</a></dt>
</dl>
<p>Ficl partially implements the following wordsets
</p>
<dl>
<dt><a href="http://ficl.sourceforge.net/dpans/dpans6.htm#6.2">Core Extensions</a>
<dt><a href="http://ficl.sourceforge.net/dpans/dpans12.htm#12.6.1">Floating Point</a>
<dt><a href="http://ficl.sourceforge.net/dpans/dpans12.htm#12.6.2">Floating Point Extensions</a>
</dt>
<dt><a href="http://ficl.sourceforge.net/dpans/dpans15.htm#15.6.s\2">Programming Tools Extensions</a></dt>
</dl>
      <H2>
        <A name="extras"></A>Ficl extras
      </H2>
      <H3>
        <A name="exnumber"></A>Number syntax
      </H3>
      You can precede a number with "0x", as in C, and it will be interpreted as a hex value regardless of the value of <CODE>BASE</CODE>. Likewise, numbers prefixed with "0d" will be interpreted as
      decimal values. Example: 
<PRE>
decimal 123 . cr
123 
ok&gt; 0x123 . cr
291 
ok&gt; 0x123 x. cr
123 ok&gt; 
</PRE>
      Note: (ficl2.05 and later) This behavior is controlled by the <A href="ficl_parse.html">prefix parser</A> defined in <CODE>prefix.c</CODE>. You can add other prefixes by defining handlers for
      them in ficl or C. 
      <H3>
        <A name="exsearch"></A>Ficl extensions to the <TT>SEARCH</TT> wordset
      </H3>
      <P>
        Ficl implements many of the search order words in terms of two primitives called <CODE><A href="#tosearch">&gt;SEARCH</A></CODE> and <CODE><A href="#searchfrom">SEARCH&gt;</A></CODE>. As
        their names suggest, the search order list is treated as a stack, and these words push and pop it.
      </P>
      <P>
        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 <CODE>ABORT</CODE>
        happens. This includes stack underflows and overflows. <CODE>QUIT</CODE> does not affect the search order. The minimum search order (set by <CODE>ONLY</CODE>) is equivalent to
      </P>
<PRE>
FORTH-WORDLIST 1 SET-ORDER
</PRE>
      <P>
        There is a default maximum of 16 wordlists in the search order. This can be changed by redefining <CODE>FICL_DEFAULT_VOCS</CODE> (declared in sysdep.h).
      </P>
      <P>
        <B>Note</B>: Ficl resets the search order whenever it does <CODE>ABORT</CODE>. If you don't like this behavior, just comment out the <CODE>dictResetSearchOrder()</CODE> lines in <CODE>
        ficlExec()</CODE>.
      </P>
      <DL>
        <DT>
          <A name="tosearch"></A>&gt;search ( wid -- )
        </DT>
        <DD>
          Push <CODE>wid</CODE> onto the search order. Many of the other search order words are written in terms of the <CODE>SEARCH&gt;</CODE> and <CODE>&gt;SEARCH</CODE> primitives. This word can
          be defined in ANS Forth as follows
        </DD>
      </DL>
<PRE>
: &gt;search   &gt;r get-order 1+ r&gt; swap set-order ;
</PRE>
      <DL>
        <DT>
          <A name="searchfrom"></A>search&gt; ( -- wid )
        </DT>
        <DD>
          Pop <CODE>wid</CODE> off the search order. Can be coded in ANS Forth as:
        </DD>
      </DL>
<PRE>
: search&gt;  get-order nip 1- set-order ;
</PRE>
      <DL>
        <DT>
          <A name="ficlsetcurrent"></A>ficl-set-current ( wid -- old-wid )
        </DT>
        <DD>
          Set wid as compile wordlist, leaving the previous compile wordlist on the stack
        </DD>
        <DT>
          <A name="ficlvocabulary"></A>ficl-vocabulary ( nBins "name" -- )
        </DT>
        <DD>
          Creates a <CODE>ficl-wordlist</CODE> with the specified number of hash table bins, binds it to the name, and associates the semantics of <CODE>vocabulary</CODE> with it (replaces the top
          wid in the search order list with its own wid when executed)
        </DD>
        <DT>
          <A name="ficlwordlist"></A>ficl-wordlist ( nBins -- wid )
        </DT>
        <DD>
          Creates a wordlist with the specified number of hash table bins, and leaves the address of the wordlist on the stack. A <CODE>ficl-wordlist</CODE> 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. <CODE>
          ficl-named-wordlist</CODE> takes a name for the wordlist and creates a word that pushes the <CODE>wid</CODE>. This is by contrast to <CODE>VOCABULARY</CODE>, which also has a name, but
          replaces the top of the search order with its <CODE>wid</CODE>.
        </DD>
        <DT>
          <A name="ficlforgetwid"></A>forget-wid ( wid -- )
        </DT>
        <DD>
          Iterates through the specified wordlist and unlinks all definitions whose xt addresses are greater than or equal to the value of <CODE>HERE</CODE>, the dictionary fill pointer.
        </DD>
        <DT>
          <A name="ficlhide"></A>hide ( -- current-wid-was )
        </DT>
        <DD>
          Push the <CODE>hidden</CODE> wordlist onto the search order, and set it as the current compile wordlist (unsing <CODE>ficl-set-current</CODE>). 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 <CODE>hide</CODE>, execute <CODE>
          previous set-current</CODE>
        </DD>
        <DT>
          <A name="ficlhidden"></A>hidden ( -- wid )
        </DT>
        <DD>
          Wordlist for storing implementation factors of ficl provided words. To see what's in there, try: <CODE>hide words previous set-current</CODE>
        </DD>
        <DT>
          <A name="wid-get-name"></A>wid-get-name ( wid -- c-addr u )
        </DT>
        <DD>
          Ficl wordlists (2.05 and later) have a name property that can be assigned. This is used by <CODE>ORDER</CODE> to list the names of wordlists in the search order.
        </DD>
        <DT>
          <A name="wid-set-name"></A>wid-set-name ( c-addr wid -- )
        </DT>
        <DD>
          Ficl wordlists (2.05 and later) have a name property that can be assigned. This is used by <CODE>ORDER</CODE> 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 <CODE>brand-wordlist</CODE>
        </DD>
        <DT>
          <A name="wid-set-super"></A>wid-set-super ( wid -- )
        </DT>
        <DD>
          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 <CODE>SEARCH-WORDLIST</CODE> 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.
        </DD>
      </DL>
      <H3>
        <A name="exuser"></A>User variables
      </H3>
      <DL>
        <DT>
          user ( -- ) name
        </DT>
        <DD>
          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 <CODE>VARIABLE</CODE>s in all other respects (you use @
          and ! on them, for example). Example:
        </DD>
      </DL>
<PRE>
user current-class
0 current-class !
</PRE>
      <H3>
        <A name="exmisc"></A>Miscellaneous
      </H3>
      <DL>
        <DT>
          -roll ( xu xu-1 ... x0 u -- x0 xu-1 ... x1 )
        </DT>
        <DD>
          Rotate u+1 items on top of the stack after removing u. Rotation is in the opposite sense to <CODE>ROLL</CODE>
        </DD>
        <DT>
          <A name="minusrot"></A>-rot ( a b c -- c a b )
        </DT>
        <DD>
          Rotate the top three stack entries, moving the top of stack to third place. I like to think of this as <CODE>1<SUP>1</SUP>/<SUB>2</SUB>swap</CODE> because it's good for tucking a single
          cell value behind a cell-pair (like an object).
        </DD>
        <DT>
          .env ( -- )
        </DT>
        <DD>
          List all environment variables of the system
        </DD>
        <DT>
          .hash ( -- )
        </DT>
        <DD>
          List hash table performance statistics of the wordlist that's first in the search order
        </DD>
        <DT>
          .ver ( -- )
        </DT>
        <DD>
          Display ficl version ID
        </DD>
        <DT>
          &gt;name ( xt -- c-addr u )
        </DT>
        <DD>
          Convert a word's execution token into the address and length of its name
        </DD>
        <DT>
          body&gt; ( a-addr -- xt )
        </DT>
        <DD>
          Reverses the effect of <CODE>CORE</CODE> word <CODE>&gt;body</CODE> (converts a parameter field address to an execution token)
        </DD>
        <DT>
          compile-only
        </DT>
        <DD>
          Mark the most recently defined word as being executable only while in compile state. Many <CODE>immediate</CODE> words have this property.
        </DD>
        <DT>
          empty ( -- )
        </DT>
        <DD>
          Empty the parameter stack
        </DD>
        <DT>
          endif
        </DT>
        <DD>
          Synonym for <CODE>THEN</CODE>
        </DD>
        <DT>
          <A name="last-word"></A>last-word ( -- xt )
        </DT>
        <DD>
          Pushes the xt address of the most recently defined word. This applies to colon definitions, constants, variables, and words that use <CODE>create</CODE>. You can print the name of the most
          recently defined word with
        </DD>
      </DL>
<PRE>
last-word &gt;name type
</PRE>
      <DL>
        <DT>
          parse-word ( &lt;spaces&gt;name -- c-addr u )
        </DT>
        <DD>
          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)
        </DD>
        <DT>
          <A name="qfetch"></A>q@ ( addr -- x )
        </DT>
        <DD>
          Fetch a 32 bit quantity from the specified address
        </DD>
        <DT>
          <A name="qbang"></A>q! ( x addr -- )
        </DT>
        <DD>
          Store a 32 bit quantity to the specified address
        </DD>
        <DT>
          w@ ( addr -- x )
        </DT>
        <DD>
          Fetch a 16 bit quantity from the specified address
        </DD>
        <DT>
          w! ( x addr -- )
        </DT>
        <DD>
          Store a 16 bit quantity to the specified address (the low 16 bits of the given value)
        </DD>
        <DT>
          <A name="xdot"></A>x. ( x -- )
        </DT>
        <DD>
          Pop and display the value in hex format, regardless of the current value of <CODE>BASE</CODE>
        </DD>
      </DL>
      <H3>
        <A name="exficlwin"></A>Extra words defined in testmain.c (Win32 and POSIX versions)
      </H3>
      <DL>
        <DT>
          break ( -- )
        </DT>
        <DD>
          Does nothing - just a handy place to set a debugger breakpoint
        </DD>
        <DT>
          cd ( "directory-name&lt;newline&gt;" -- )
        </DT>
        <DD>
          Executes the Win32 chdir() function, changing the program's logged directory.
        </DD>
        <DT>
          <A name="clock"></A>clock ( -- now )
        </DT>
        <DD>
          Wrapper for the ANSI C clock() function. Returns the number of clock ticks elapsed since process start.
        </DD>
        <DT>
          <A name="clockspersec"></A>clocks/sec ( -- clocks_per_sec )
        </DT>
        <DD>
          Pushes the number of ticks in a second as returned by <CODE>clock</CODE>
        </DD>
        <DT>
          <A name="ficlload"></A>load ( "filename&lt;newline&gt;" -- )
        </DT>
        <DD>
          Opens the Forth source file specified and loads it one line at a time, like <CODE>INCLUDED (FILE)</CODE>
        </DD>
        <DT>
          pwd ( -- )
        </DT>
        <DD>
          Prints the current working directory as set by <CODE>cd</CODE>
        </DD>
        <DT>
          system ( "command&lt;newline&gt;" -- )
        </DT>
        <DD>
          Issues a command to a shell; implemented with the Win32 system() call.
        </DD>
        <DT>
          spewhash ( "filename&lt;newline&gt;" -- )
        </DT>
        <DD>
          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.
        </DD>
      </DL>
      <H3>
        Words defined in FiclWin only
      </H3>
      <DL>
        <DT>
          !oreg ( c -- )
        </DT>
        <DD>
          Set the value of the simulated LED register as specified (0..255)
        </DD>
        <DT>
          @ireg ( -- c )
        </DT>
        <DD>
          Gets the value of the simulated switch block (0..255)
        </DD>
        <DT>
          !dac ( c -- )
        </DT>
        <DD>
          Sets the value of the bargraph control as specified. Valid values range from 0..255
        </DD>
        <DT>
          @adc ( -- c )
        </DT>
        <DD>
          Fetches the current position of the slider control. Range is 0..255
        </DD>
        <DT>
          status" ( "ccc&lt;quote&gt;" -- )
        </DT>
        <DD>
          Set the mainframe window's status line to the text specified, up to the first trailing quote character.
        </DD>
        <DT>
          <A name="ficlms" href="http://ficl.sourceforge.net/dpans/dpans10.htm#10.6.2.1905">ms</A> ( u -- )
        </DT>
        <DD>
          Causes the running virtual machine to sleep() for the number of milliseconds specified by the top-of-stack value.
        </DD>
      </DL>
    </DIV>
  </BODY>
</HTML>