emacs-devel
[Top][All Lists]
Advanced

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

Re: Lexical byte-compilation warnings cleanup


From: Stefan Monnier
Subject: Re: Lexical byte-compilation warnings cleanup
Date: Wed, 21 Aug 2013 00:49:22 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux)

>> > And the intention is?  The design is?  The reason is?

Check the calling convention used by the new byte-code representation
(used for lexically scoped code) and you'll see that there's no support
for dynamic scoping in it.  Adding such support "natively" would
slow down the common case too much.

We could support dynamically-scoped args in lexically-scoped byte-code
by tweaking the byte-compiler, but then the byte-code that the
byte-compiler needs to generate is the same as the one you get with:

   (defun foo (lexarg)
     (let ((dynvar lexarg))
       ...))

So I prefer to make the extra cost of the separate `let' binding
explicit in the source code.  Especially since it has various beneficial
side-effects:
- simpler byte-compiler.
- slightly more efficient handling of function calls for
  lexically-scoped interpreted code (this is actually less beneficial
  than I thought at first, tho).
- IMNHO better style (I have always found it confusing when dynvars were
  bound as function arguments rather than by a let-binding).
- having a separate `let' often allows you to move it to a better place,
  and/or to add useful code between the function header and the let
  binding (such as the defvar that causes the variable to be
  dynamically bound).

BTW, I have never seen a dynamically-scoped argument used in
Common Lisp.


        Stefan



reply via email to

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