Contexts and macros

Pondering the philosophy behind the language
Locked
Jeff
Posts: 604
Joined: Sat Apr 07, 2007 2:23 pm
Location: Ohio
Contact:

Contexts and macros

Post by Jeff »

If the preferred method to avoid variable capture is to use lexically scoped macros, why not make all macros lexically scoped by default? Why not have the reader implicitly read local variables in a macro as if the macro were written:

Code: Select all

(context 'my-macro)
(define-macro (my-macro ...)
  ...)
(context 'previous-context)
Jeff
=====
Old programmers don't die. They just parse on...

Artful code

Kazimir Majorinc
Posts: 388
Joined: Thu May 08, 2008 1:24 am
Location: Croatia
Contact:

Post by Kazimir Majorinc »

Maybe because these features are really independent, i.e. these can, but do not have to go together. It is easier to keep them separated and combine if appropriate. Specifically, I can think about three different situations:

(1) very simple programs and learning of Newlisp - for such situations contexts are overkill.
(2) normal applications or libraries - contexts are simple and efficient.
(3) rare but hard funarg problems, possible if, for example, function / macro calls itself. For that, contexts are not enough.

itistoday proposed the same few months ago: http://www.alh.net/newlisp/phpbb/viewtopic.php?t=2714 ; he actually advocated less - special "safe" define-smacro, beside, not instead current define-macro. I thought that even that shouldn't be part of the standard (hence, burden on maintenance, documentation, justification on Lutz), but that it is better if it is part of some private library, so everyone can use it, yet it can be still considered unofficial or experimental.

Locked