[CM] AI recursion?

Bill Gribble grib@linuxdevel.com
23 Oct 2002 16:02:05 -0500


On Wed, 2002-10-23 at 15:22, Carr Wilkerson wrote:
> 	I remember learning once about the ability of Common Lisp to 
> somehow produce code and read it at runtime.  Can anyone just give me the 
> key/buzz words for this functionality? 

You want to look for information on the "read-eval-print loop" or
"repl".  The REPL is what runs the interactive command interpreter that
you get when you run most LISPs with no input files. 

Basically it does just what it says when you type at it (this is
oversimplifying a bit, forgetting about things like macros):
  - read: the string "(+ 234 567)" is turned into the Lisp list 
    (+ 234 567) where + is the symbol '+
  - eval: a lisp data type is recursively "evaluated".  Literal data, 
    like numbers and literal strings, evaluates to itself; lists 
    are evaluated as function calls where the first argument is looked
    up as a function.  So (+ 234 567) evaluates to 801.
  - print: the lisp object returned by "eval" is converted into a string
    and displayed: 801 --> "801". 

You can build a list within your program and call "eval" on it if you
want to dynamically generate and run code.  You can also take in the
code as strings, then "read" and "eval". 

b.g.