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 3 of 15 Topic 13120 of 13806
Post > Topic >>

Re: Capturing a function in a closure

by Glenn Willen <gwillen@[EMAIL PROTECTED] > Jul 22, 2008 at 09:35 PM

In article <6emqgpF7pnpkU1@[EMAIL PROTECTED]
>, Pascal Costanza wrote:
> Yes, this is a terrible hack. It's ugliness will manifest itself when 
> you attempt to file-compile code with such references:
> 
> (defun foo (x) x)
> 
> (defun bar (x) (apply #.#'foo (list x)))
> 
> If you file-compile such code, the compiler will complain because the 
> function foo is not defined yet at readtime.

Right, this is why I emphasized read-time. What I really want to capture
is
function-definition-evaluation-time. Unfortunately I've done very little
working with or thinking about compilation versus interpretation, which
means
there are more 'times' than I'm really comfortable with.
> 
> What you want is load-time-value:
> 
> (defun foo (x) x)
> 
> (defun bar (x) (apply (load-time-value #'foo) (list x)))

Interesting! That's a form I've never heard of before. The CLHS suggests
it is
indeed precisely what I was looking for. Is "load time" always the same as
the
time at which the function definition is evaluated? (I guess in the
compiled
universe, there's no such time, just the time at which it's compiled and
the
time at which the image is loaded, this being the latter. In the
interpreted
universe I guess "load-time" is treated as precisely what I want, though.)

Thanks a lot!
gwillen
 




 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 Sat Nov 22 7:59:56 CST 2008.