Jason <jemeade@gmail.com> wrote:
+---------------
| I'm hangin' out with Lambda, the Ultimate, and he showed me a cool new
| trick!
|
| [4]> (eval ((lambda (x) (* x x)) 5))
| 25
| [5]> (funcall (coerce '(lambda (x) (* x x)) 'function) 5)
| 25
| [6]>
|
| I've known about item 4 for a while, but just discovered 5 tonight. 5
| seems... better, but I can't say why.
|
| Aside from stylistic concerns, is one form preferred over the other,
| and if so then why?
+---------------
Why do either when this is perfectly legal?!?
> ((lambda (x) (* x x)) 5)
25
>
Plus, the latter can be compiled and/or inlined, as the CLHS notes:
3.1.2.1.2.4 Lambda Forms
...
(In practice, some compilers are more likely to produce inline code
for a lambda form than for an arbitrary named function that has been
declared inline; however, such a difference is not semantic.)
...
-Rob
-----
Rob Warnock <rpw3@rpw3.org>
627 26th Avenue <URL:http://rpw3.org/>
San Mateo, CA 94403 (650)572-2607