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

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

Re: About function parameters, is it a bug of elisp interpreter?


From: Lee David
Subject: Re: About function parameters, is it a bug of elisp interpreter?
Date: Tue, 22 May 2007 14:03:07 +0800

On 5/22/07, Trent Buck <trentbuck@gmail.com> wrote:
Elisp does not have Scheme-style block structure.  DEFUN always
changes the global procedure definition.  This can be demonstrated
trivially:

    ;; in Emacs
    ELISP> (defun f ()
             (defun g ()
               2)
             (g))
    f
    ELISP> (f)
    2
    ELISP> (fboundp 'g)
    t

    ;; in Scheme
    #;1> (define (f)
           (define (g)
             2)
           (g))
    #;2> (f)
    2
    #;3> g
    Error: unbound variable: g

Yes, I've already known this by trial.

Similarly, R5RS Scheme always uses lexical scoping, whereas elisp is
dynamically scoped (by default).

    ;; in Emacs
    ELISP> (defvar x 2)
    x
    ELISP> (defun f ()
             x)
    f
    ELISP> (let ((x 3))
             (f))
    3

    ;; in Scheme
    #;1> (define x 2)
    #;2> (define (f)
           x)
    #;3> (let ((x 3))
           (f))
    2

Thanks for your explanation, and it should be the key to answer my confusion.

These are not so much bugs as simply different semantics.  You will
need to understand them in order to correctly translate code between
Scheme and elisp.

A sensational subject may be apt to draw eyeballs. :)
Thanks very much.

--
Trent Buck



_______________________________________________
bug-gnu-emacs mailing list
bug-gnu-emacs@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-gnu-emacs



--
Thanks,
Li Qun




reply via email to

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