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 2 of 15 Topic 13120 of 13900
Post > Topic >>

Re: Capturing a function in a closure

by Pascal Costanza <pc@[EMAIL PROTECTED] > Jul 22, 2008 at 09:25 PM

Glenn Willen wrote:

> One way to accomplish very nearly what I want is to use #. to refer to
the
> value of list which exists at _read time_ when the definition of my-list
is
> _read_. This strikes me as a terrible hack:
> 
> (defun my-list (&rest args) (apply #.#'list args))
> 
> Is there another way? (For that matter, does this way always do what I
think it
> does?)

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.

What you want is load-time-value:

(defun foo (x) x)

(defun bar (x) (apply (load-time-value #'foo) (list x)))


Pascal

-- 
My website: http://p-cos.net
Common Lisp Do***ent Repository: http://cdr.eurolisp.org
Closer to MOP & ContextL: http://common-lisp.net/project/closer/
 




 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:04:46 CST 2008.