Contexts and macros

Started by Jeff, October 07, 2009, 06:37:18 AM

Previous topic - Next topic

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:


(context 'my-macro)
(define-macro (my-macro ...)
  ...)
(context 'previous-context)
Jeff

=====

Old programmers don\'t die. They just parse on...



http://artfulcode.net\">Artful code

Kazimir Majorinc

#1
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">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.
http://kazimirmajorinc.com/\">WWW site; http://kazimirmajorinc.blogspot.com\">blog.