Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!usc!cs.utexas.edu!hellgate.utah.edu!defmacro.utah.edu!moore From: moore%defmacro.utah.edu@cs.utah.edu (Tim Moore) Newsgroups: comp.lang.lisp Subject: Re: AKCL dynamic symbol table - HELP needed Message-ID: <1991Apr3.134053.8574@hellgate.utah.edu> Date: 3 Apr 91 20:40:53 GMT References: <8693@ucdavis.ucdavis.edu> Organization: University of Utah CS Dept Lines: 36 In article <8693@ucdavis.ucdavis.edu> gfink@iris.UCDavis.EDU (George Fink) writes: >I am working on a program to be written in AKCL, and I wish to have >dynamically created lambda expressions which have some sort of static >symbol information specific to the expression. Is there a simple >way/package to implement this, or is the best way to manually create a >self-modifying a-list (or similar structure) to store the permanent >information? The best way to do this is to use closures. >For example, say I have the following expression (excuse syntactic errors):` > >(lambda () (let ((c 0)) (setq c (1+ c)) (if (= c 10) (do something)))) You would want to write that as (let ((c 0)) #'(lambda () (setq c (1+ c)) (if (= c 10) (do-something)))) This expression returns a lambda that when called will do what you want to do. >between calls. But I am going to be creating these lambda expressions >on the fly, >albiet in some standard formats. I'm not sure what you mean by this. The above expression will create a fresh lambda every time it is evaluated, with a new "cell" for c. If you are contemplating consing up lambda expressions and EVALing them, you might want to rethink your approach. -- Tim Moore moore@cs.utah.edu {bellcore,hplabs}!utah-cs!moore "Ah, youth. Ah, statute of limitations." -John Waters