[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
- Re: Lexical byte-compilation warnings cleanup, (continued)
- Re: Lexical byte-compilation warnings cleanup, Juanma Barranquero, 2013/08/19
- Re: Lexical byte-compilation warnings cleanup, Glenn Morris, 2013/08/19
- Re: Lexical byte-compilation warnings cleanup, Stefan Monnier, 2013/08/20
- RE: Lexical byte-compilation warnings cleanup, Drew Adams, 2013/08/20
- Re: Lexical byte-compilation warnings cleanup, Stefan Monnier, 2013/08/20
- RE: Lexical byte-compilation warnings cleanup, Drew Adams, 2013/08/20
- Re: Lexical byte-compilation warnings cleanup, Stefan Monnier, 2013/08/20
- RE: Lexical byte-compilation warnings cleanup, Drew Adams, 2013/08/20
- RE: Lexical byte-compilation warnings cleanup, Stephen J. Turnbull, 2013/08/20
- RE: Lexical byte-compilation warnings cleanup, Drew Adams, 2013/08/20
- Re: Lexical byte-compilation warnings cleanup,
Stefan Monnier <=
- Re: Lexical byte-compilation warnings cleanup, Dmitri Paduchikh, 2013/08/21
- Re: Lexical byte-compilation warnings cleanup, Stefan Monnier, 2013/08/21
Re: Lexical byte-compilation warnings cleanup, Barry OReilly, 2013/08/21