In the different CL implementations, what is more efficient?
(funcall #'(lambda <arglist> <forms>) <args>)
or
(flet ((fun <arglist> <forms>))
(declare (dynamic-extent #'fun))
(fun <args>))
?
Also, which ones will generate overhead when the above
function definitions happen inside a loop, when they could be bound
surrounding it?
Thanks in advance,
--
Fernando D. Mato Mira
Real-Time SW Eng & Networking
Advanced Systems Engineering Division
CSEM
Jaquet-Droz 1 email: matomira AT acm DOT org
CH-2007 Neuchatel tel: +41 (32) 720-5157
Switzerland FAX: +41 (32) 720-5720
www.csem.ch www.vrai.com ligwww.epfl.ch/matomira.html
In article <·················@iname.com>,
Fernando D. Mato Mira <········@iname.com> wrote:
>In the different CL implementations, what is more efficient?
>
>(funcall #'(lambda <arglist> <forms>) <args>)
>
>or
>
>(flet ((fun <arglist> <forms>))
> (declare (dynamic-extent #'fun))
> (fun <args>))
>
>?
>
>Also, which ones will generate overhead when the above
>function definitions happen inside a loop, when they could be bound
>surrounding it?
I would expect most implementations to optimize the two forms to the same
code. In fact, you shouldn't even need the DYNAMIC-EXTENT declaration,
since the compiler can see that #'FUN is never passed around as data, so it
can't be referenced outside the lexical and dynamic extent of the FLET.
--
Barry Margolin, ······@bbnplanet.com
GTE Internetworking, Powered by BBN, Burlington, MA
*** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.
Please DON'T copy followups to me -- I'll assume it wasn't posted to the group.
Barry Margolin wrote:
> code. In fact, you shouldn't even need the DYNAMIC-EXTENT declaration,
> since the compiler can see that #'FUN is never passed around as data, so it
> can't be referenced outside the lexical and dynamic extent of the FLET.
I'm just paranoid ;)
--
Fernando D. Mato Mira
Real-Time SW Eng & Networking
Advanced Systems Engineering Division
CSEM
Jaquet-Droz 1 email: matomira AT acm DOT org
CH-2007 Neuchatel tel: +41 (32) 720-5157
Switzerland FAX: +41 (32) 720-5720
www.csem.ch www.vrai.com ligwww.epfl.ch/matomira.html
"Fernando D. Mato Mira" wrote:
> In the different CL implementations, what is more efficient?
>
> (funcall #'(lambda <arglist> <forms>) <args>)
>
> or
>
> (flet ((fun <arglist> <forms>))
> (declare (dynamic-extent #'fun))
> (fun <args>))
>
> ?
I guess the answer should be this:
((lambda <arglist> <forms>) <args>)
Except that the loop question still stands.
--
Fernando D. Mato Mira
Real-Time SW Eng & Networking
Advanced Systems Engineering Division
CSEM
Jaquet-Droz 1 email: matomira AT acm DOT org
CH-2007 Neuchatel tel: +41 (32) 720-5157
Switzerland FAX: +41 (32) 720-5720
www.csem.ch www.vrai.com ligwww.epfl.ch/matomira.html