help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Learning LISP; Scheme vs elisp.


From: David Kastrup
Subject: Re: Learning LISP; Scheme vs elisp.
Date: Fri, 01 Aug 2008 22:18:24 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux)

"Joel J. Adamson " <address@hidden> writes:

>>>>>> "Adam" == Adam Funk <address@hidden> writes:
>
>     Adam> I've decided I ought to train myself in the most elegant
>     Adam> programming weapon --- http://xkcd.com/297/ --- so I've
>     Adam> started working through _The Structure and Interpretation of
>     Adam> Computer Programs_.
>
>     Scheme:
>
> ,----
> | Gambit v4.2.8
> | 
> | > (define lis '(1 2 3 4))
> |   (apply + lis)
> | > 10
> `----
>
>     Emacs:
>     
> ,----
> | ELISP> (apply + '(1 2 3 4))
> | *** Eval error ***  Symbol's value as variable is void: +
> | ELISP> (apply '+ '(1 2 3 4))
> | 10  
> `----

That's actually not the same because apply then gets a quoted symbol
rather than a dereferenced function cell.  The equivalent would be
(apply (symbol-function '+) '(1 2 3 4))

Check this:

guile> +
#<primitive-generic +>

ELISP> '+
+
ELISP> (symbol-function '+)
#<subr +>


>
>     Common Lisp:

> | [7]> (apply #'+ lis)
> | 10

Works in Emacs as well, obviously.

-- 
David Kastrup, Kriemhildstr. 15, 44793 Bochum


reply via email to

[Prev in Thread] Current Thread [Next in Thread]