emacs-devel
[Top][All Lists]
Advanced

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

Re: macros and the lexical environment


From: Stefan Monnier
Subject: Re: macros and the lexical environment
Date: Tue, 04 Jun 2013 21:48:05 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux)

>   (let ((v 42)
>         (a "hello world")
>         (template "${a} - the answer is ${v}"))
>      (s-lex-format template))

> will fail to expand.

Sounds fair: lexical scoping basically means that variables don't really
have a name (the name is just a way to make it easy for the programmer to
specify which use corresponds to which variable declaration).

If you want to be able to share templates, then you can do:

   (let ((v 42)
         (a "hello world")
         (template (lambda () (s-lex-format "${a} - the answer is ${v}"))))
      (funcall template))

> to do? get at the current environment state? the interpreter must know
> the environment state.

Which interpreter?  The byte-code interpreter knows the state, but not
the names, which have been thrown away during byte-compilation.

> Could it be exposed to macros at compile time?

What would "it" be, exactly?

I mean: yes we could theoretically provide to macros some info about the
lexical environment, tho it couldn't be much more than "here is the list
of variables in the current lexical environment".

What would you use it for?


        Stefan



reply via email to

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