diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2015-08-03 07:13:49 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2015-08-03 07:13:49 -0700 |
commit | f135cd3637d39c46d21222f48178212b58fdad76 (patch) | |
tree | 148e4cec2a540bd751806071856f49e5da07cdcc /txr.1 | |
parent | 64d3f8fcc8ef6e83e6fd789614e1aadfa526d18d (diff) | |
download | txr-f135cd3637d39c46d21222f48178212b58fdad76.tar.gz txr-f135cd3637d39c46d21222f48178212b58fdad76.tar.bz2 txr-f135cd3637d39c46d21222f48178212b58fdad76.zip |
Introducing global lexicals: defvarl, defparml.
* eval.c (defvarl_s, defparm_s, defparml_s, sys_mark_special_s): New
symbol variables.
(mark_special): Return val rather than void, since it's hoisted
into Lisp domain now with func_n1.
(op_defvar): Renamed to op_defvarl, and doesn't call mark_special.
defvarl is now the special form for defining variables, and special
marking is an embellishment added by macros.
(me_defparm): Renamed to me_def_variable. Handles defvar, defparm
and defparml.
(do_expand): Expand defvarl, rather than defvar.
(eval_init): Intern defvarl, defparm, defparml and mark-special
symbols, and initialize corresponding globals.
Register defvarl special operator, retiring defvar.
Register defparm to me_def_variable, and register defvar and
defparml to the same.
* txr.1: Document support for global lexical scopes and the
new macros.
Diffstat (limited to 'txr.1')
-rw-r--r-- | txr.1 | 53 |
1 files changed, 47 insertions, 6 deletions
@@ -9086,7 +9086,10 @@ is also the empty list, which terminates nonempty lists. similarly to Common Lisp, including the convention that .code defvar marks symbols for dynamic binding in local scopes. Lexical closures -are supported. Functions are lexically scoped in \*(TL; they can be +are supported. \*(TL also supports global lexical variables via +.codn defvarl . + +Functions are lexically scoped in \*(TL; they can be defined in pervasive global environment using .code defun or in local scopes using @@ -10429,14 +10432,12 @@ a form are fully expanded prior to the evaluation of a form, therefore evaluation does not consider the possibility of a symbol being a symbol macro. -.coNP Operators @ defvar and @ defparm +.coNP Operator @ defvar and macro @ defparm .synb .mets (defvar < sym <> [ value ]) .mets (defparm < sym << value ) .syne - .desc - The .code defvar operator binds a name in the variable namespace of the global environment. @@ -10488,7 +10489,7 @@ above. The .code defparm -operator behaves like +macro behaves like .code defvar when a variable named .meta sym @@ -10512,9 +10513,49 @@ The .code defvar and .code defparm -operators return +forms return .metn sym . +.coNP Macros @ defvarl and @ defparml +.synb +.mets (defvarl < sym <> [ value ]) +.mets (defparml < sym << value ) +.syne +.desc +The +.code defvarl +and +.code defparml +macros behave, respectively, almost exactly like +.code defvar +and +.codn defparm . + +The difference is that these operators do not mark +.meta sym +as special. + +If a global variable +.meta sym +does not previously exist, then after the evaluation of +either of these forms +.cblk +.meti (boundp << sym ) +.cble +is true, but +.cblk +.meti (special-var-p << sym ) +.cble +isn't. + +If +.meta sym +had been already introduced as a special variable, it stays that way +after the evaluation of +.code defvarl +or +.codn defparml . + .coNP Operators @ let and @ let* .synb .mets (let >> ({ sym | >> ( sym << init-form )}*) << body-form *) |