home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.lang.forth      Forth programmers eat a lot of Bratwurst      117,927 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 117,367 of 117,927   
   albert@spenarnc.xs4all.nl to All   
   What is lucky7 (was RE: What is Forth?)   
   01 Jul 25 23:28:11   
   
   lucky7 is a database of small programs.   
   The database is called the dictionary.   
   The programs are called word's, or definitions.   
   The explanation of words from the dictionary is called   
   a glossary.   
      
   First of all, a lucky7 system is an environment that you enter by   
   running it:   
      
   prompt> lucky7   
      
   Like in a Disk Operating System a word is executed   
   by typing its name, but unlike in a DOS several programs   
   can be specified on the same line, interspersed with   
   numbers. Also names can be anything, as long as they don't   
   contain spaces.   
      
   A program may leave one or more results,   
   and the next program can use it.   
   The latest result is used up first, hence the name lifo buffer.   
   (last in, first out).   
      
   For example:   
      
   lucky7 example:   
   "   
   1 2 + 7 *   
    OK   
   .   
   21   
   "   
   1 2 and 7 are numbers and are just remembered as they are typed in.   
   OK and 21 OK are the answer of the computer.   
   `` + '' is a small program with an appropriate name.   
   It adds the two numbers that were entered the latest, in this   
   case 1 and 2. The result 3 remains, but 1 and 2 are consumed.   
   Note that a name can be anything, as long as it doesn't contain   
   spaces.   
   The program `` * '' multiplies the 3 and the 7 and the result is 21.   
   The program `` . '' prints this results. It could have   
   been put on the same line equally easily.   
      
   You will be curious about what are all those commands available.   
   Of course they are documented, but you can find the exact set   
   by typing "lsn" .   
   Programs can be added to the database by special programs: the so   
   called defining word's.   
   A defining word generally gets the name of the   
   new word from the input line.   
      
   For example: a constant is just a program that leaves always   
   the same value.   
   A constant is created in this way, by the defining word CONSTANT :   
      
       127 CONSTANT MONKEY   12 .   
       12 OK   
      
   You can check that it has been added, by typing lsn again.   
      
   The above  must not be read like:   
        a number, two programs and again a number etc.... ,   
   but as:   
       a number, a program and a name that is consumed,   
   and after that   
   life goes on. The `` 12 .  '' we put there for demonstration purposes,   
   to show that CONSTANT reads ahead only one word.   
   On this single line we do two things, defining MONKEY and printing the   
   number 12.   
   We see that CONSTANT like any other program consumes some   
   data, in this case the 127 that serves as an initial value for   
   the constant called  MONKEY .   
   You can combine programs with { and } like so:   
      
   { 1 2 + 7 * }     17 .   
       17 OK   
      
   The commands between { and } are not executed directly, the sequence   
   leaves a recipee.   
   It can be RUN.   
      
   RUN .   
   21 OK   
      
   You can give a recipee a name, analogous to CONSTANT   
   { 1 2 + 7 * } : TEST   
   OK   
      
   Now you can use TEST like all other words in de the dictionary.   
      
       TEST TEST + .   
       42  OK   
       : TEST+1 TEST 1 + . ;  TEST+1   
       22 OK   
      
   We see that TEST can be used as a building block.   
      
   The colon allows the lucky7 programmer to add new programs   
   easily and test them easily, by typing them at the keyboard.   
   It is considered bad style if a program is longer than   
   a couple of lines.   
      
   You can interrupt the creation of a recipee by [ ] to   
   give direct commands.   
   For example   
   { TEST-AGAIN  [ 12 CONSTANT twelve ]   
       twelve twelve + 3 * }   
      OK   
   Here you add a constant to the dictionary, and use it.   
   to normal (interpret) mode by `` [  '' , and back   
   by `` ]  ''.   
   (There is a restriction, you cannot leave anything behind).   
      
   Groetjes Albert   
      
   P.S. Note that it is shorter and makes more sense than the definition   
   of Forth.   
   --   
   The Chinese government is satisfied with its military superiority over USA.   
   The next 5 year plan has as primary goal to advance life expectancy   
   over 80 years, like Western Europe.   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca