Re: lisp basic question
Tiago Maduro-Dias <[email protected]> Wed, 21 Apr 2004 17:47:16 +0200
| Newsgroups | gmane.lisp.allegro |
|---|---|
| Message-ID | <[email protected]> |
Heya! On Wed, 2004-04-21 at 16:33, paolo viappiani wrote: [...] > > (defun p (x) x) > >(p 3) > 3 > >p > error: attempt to take the value of the unbound variable p > > It would nice instead that if I type in the name of the function the > system replies telling me the body of the function!! First some some quick, maybe useless, background. :) Unlike other Lisp dialects, such as Scheme, Common Lisp has separate name spaces for variables and functions. When a name occurs first in a function call, or is preceded by a sharp-quote, it is taken to refer to a function. Otherwise it is treated as a variable name. That's what happens when you just type it at the top-level. The symbols value slot is accessed. Try running (symbol-value 'p), the error will be the same. If you run (symbol-function 'p) or (fdefinition 'p) you can access the function itself, but by now the body will have been interpreted and converted to some inner representation. You will get something like #<Interpreted Function p>. Now, to answer your question, there is also a function defined in the ANSI Common Lisp standard which does pretty much what you wanted, function-lambda-expression: > cl-user(13): (function-lambda-expression #'p) > (lambda (x) (block p)) > nil > p Documentation for this function is available from: http://www.franz.com/support/documentation/6.2/ansicl/dictentr/functio2.htm > second question: how can I save the current environment (binding > symbols/values, function definition and so on..) of the interpreter (in > ACL 6.2, of a listener) for load it afterward? If I understand you correctly you may want to check the documentation for building lisp images: http://www.franz.com/support/documentation/6.2/doc/building-images.htm > third question: how can I make a script file with command likes change > directory, load these files and so on? If what you're looking for is something of the likes of a makefile for project management, you may want to look at defsystem: http://www.franz.com/support/documentation/6.2/doc/defsystem.htm If this is not what you wanted, could you be a bit more specific? Hope this helps! :) Tiago. -- "I conjecture that there is no good algorithm for the traveling salesman problem. My reasons are the same as for any mathematical cojecture: (1) It is a legitimate mathematical possiblity, and (2) I do not know." --Jack Edmonds, 1966