Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Lisp > Re: Capturing a...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 13 of 15 Topic 13120 of 13900
Post > Topic >>

Re: Capturing a function in a closure

by Kent M Pitman <pitman@[EMAIL PROTECTED] > Jul 24, 2008 at 07:37 PM

Kaz Kylheku <kkylheku@[EMAIL PROTECTED]
> writes:

> You don't always have the luxury of being able to set up this lexical
> environment. For instance you have no way to do this in a macro.
> 
> What if this is the case:
> 
>  (defun my-list (&rest args) (some-macro args))
> 
> SOME-MACRO cannot generate the (let ...) around the DEFUN.

Right.  Well, this is the thing for which there is LOAD-TIME-VALUE.
For anyone not remembering the history... and there are days where I'm
not sure I do either...

I vaguely recall that in Maclisp there was a magic list [a random
place in my memory says it was called the "pratt stack" (probably
named after Vaughan Pratt, of CGOL fame, since JonL White maintained
the compiler and liked to name language features after people that
requested them)] onto which you could push definitions when you were
expanding a macro in compiled code (in interpreted code, I think you
just called EVAL to effect the definition immediately--Maclisp had
tons of places where the interpreter and compiler behaved in utterly
different ways.  Things pushed onto this list would end up compiled in
along with whatever was being prepared for evaluation, so macros could
rely on auxiliary functions getting compiled to sup****t them.  It
might even have gotten the order right (making sure the auxiliary
function was compiled before the macro that needed it), though I don't
recall for sure ... that might be why it was called a stack.

In CL for a while, one used to just arrange to construct and compile 
objects at load time, with quoted constant values that could still be
modified.  The language definition is still a little blurry around that
question, since at some point we intended LOAD-TIME-VALUE to be used for
that but I'm not sure we 100% closed the door to modifiable constants
for evaluation... but I don't recommend anyone use them since there's no
need.  

LOAD-TIME-VALUE, incidentally, had its origin in an earlier weird compiler
only constant [a magic otherwise-uninterned symbol, whose name was SQUID,
for self-quoting internal datum] that you could find on a secret obarray
(kind of like a package, but not as high tech) and could cons in with an
expression causing the compiler to emit code for runtime ... I think that
was how Maclisp's #, was implemented in the compiler. (In the interpreter
it acted like #. as I recall.)

The CL way of doing this is much cleaner.
 




 15 Posts in Topic:
Capturing a function in a closure
Glenn Willen <gwillen@  2008-07-22 21:10:44 
Re: Capturing a function in a closure
Pascal Costanza <pc@[E  2008-07-22 21:25:13 
Re: Capturing a function in a closure
Glenn Willen <gwillen@  2008-07-22 21:35:38 
Re: Capturing a function in a closure
Rainer Joswig <joswig@  2008-07-22 21:43:39 
Re: Capturing a function in a closure
Vassil Nikolov <vnikol  2008-07-23 00:41:34 
Re: Capturing a function in a closure
pjb@[EMAIL PROTECTED] (P  2008-07-23 08:45:17 
Re: Capturing a function in a closure
Kent M Pitman <pitman@  2008-07-22 17:00:06 
Re: Capturing a function in a closure
Vassil Nikolov <vnikol  2008-07-23 00:44:01 
Re: Capturing a function in a closure
Barry Margolin <barmar  2008-07-23 05:03:35 
Re: Capturing a function in a closure
pjb@[EMAIL PROTECTED] (P  2008-07-23 11:38:17 
Re: Capturing a function in a closure
Vassil Nikolov <vnikol  2008-07-23 23:38:42 
Re: Capturing a function in a closure
Kaz Kylheku <kkylheku@  2008-07-24 19:12:41 
Re: Capturing a function in a closure
Kent M Pitman <pitman@  2008-07-24 19:37:56 
Re: Capturing a function in a closure
Kent M Pitman <pitman@  2008-07-24 19:26:00 
Re: Capturing a function in a closure
Kaz Kylheku <kkylheku@  2008-07-24 19:08:23 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Wed Dec 3 18:07:46 CST 2008.