From: George Fink
Subject: AKCL dynamic symbol table - HELP needed
Date: 
Message-ID: <8693@ucdavis.ucdavis.edu>
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?

For example, say I have the following expression (excuse syntactic errors):`

(lambda () (let ((c 0)) (setq c (1+ c)) (if (= c 10) (do something))))

which is called intermittantly from my code - obviously, I want c to
remain there
between calls.  But I am going to be creating these lambda expressions
on the fly,
albiet in some standard formats.

Thanks, if you can help.  Email me please.

George Fink			|  ·····@iris.eecs.ucdavis.edu
University of California, Davis	|  ucbvax!ucdavis!iris!gfink
From: Tim Moore
Subject: Re: AKCL dynamic symbol table - HELP needed
Date: 
Message-ID: <1991Apr3.134053.8574@hellgate.utah.edu>
In article <····@ucdavis.ucdavis.edu> ·····@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                    ·····@cs.utah.edu {bellcore,hplabs}!utah-cs!moore
"Ah, youth. Ah, statute of limitations."
		-John Waters