diff options
-rw-r--r-- | eval.c | 26 | ||||
-rw-r--r-- | parser.c | 2 | ||||
-rw-r--r-- | share/txr/stdlib/compiler.tl | 12 | ||||
-rw-r--r-- | txr.1 | 3 |
4 files changed, 33 insertions, 10 deletions
@@ -1965,7 +1965,7 @@ static val op_or(val form, val env) static val rt_defvarl(val sym) { - val self = lit("defvar"); + val self = lit("sys:defvarl"); val new_p; val cell = (lisplib_try_load(sym), gethash_c(self, top_vb, sym, mkcloc(new_p))); @@ -1980,15 +1980,32 @@ static val rt_defvarl(val sym) return nil; } +static val rt_defv(val sym) +{ + val self = lit("sys:defv"); + val new_p; + val cell = (lisplib_try_load(sym), + gethash_c(self, top_vb, sym, mkcloc(new_p))); + + if (new_p) { + uw_purge_deferred_warning(cons(var_s, sym)); + uw_purge_deferred_warning(cons(sym_s, sym)); + remhash(top_smb, sym); + return sys_rplacd(cell, cons(sym, nil)); + } + + return nil; +} + static val op_defvarl(val form, val env) { val args = rest(form); val sym = first(args); - val cell = rt_defvarl(sym); + val bind = rt_defv(sym); - if (cell) { + if (bind) { val value = eval(second(args), env, form); - rplacd(cell, cons(sym, value)); + rplacd(bind, value); } return sym; @@ -7180,6 +7197,7 @@ void eval_init(void) reg_varl(intern(lit("cptr-null"), user_package), cptr(0)); reg_fun(intern(lit("rt-defvarl"), system_package), func_n1(rt_defvarl)); + reg_fun(intern(lit("rt-defv"), system_package), func_n1(rt_defv)); reg_fun(intern(lit("rt-defun"), system_package), func_n2(rt_defun)); reg_fun(intern(lit("rt-defmacro"), system_package), func_n3(rt_defmacro)); reg_fun(intern(lit("rt-defsymacro"), system_package), func_n2(rt_defsymacro)); @@ -743,7 +743,7 @@ static val read_file_common(val self, val stream, val error_stream, val compiled if (compiled && first) { val major = car(form); - if (neq(major, num_fast(6))) + if (neq(major, num_fast(6)) && neq(major, num_fast(7))) uw_throwf(error_s, lit("cannot load ~s: version number mismatch"), stream, nao); diff --git a/share/txr/stdlib/compiler.tl b/share/txr/stdlib/compiler.tl index 2dba0bbe..0e0f3f4f 100644 --- a/share/txr/stdlib/compiler.tl +++ b/share/txr/stdlib/compiler.tl @@ -1982,10 +1982,12 @@ (defun expand-defvarl (form) (mac-param-bind form (op sym : value) form (with-gensyms (cell) - ^(let ((,cell (sys:rt-defvarl ',sym))) - (if ,cell - (usr:rplacd ,cell (cons ',sym ,value))) - ',sym)))) + (if value + ^(let ((,cell (sys:rt-defv ',sym))) + (if ,cell + (usr:rplacd ,cell ,value)) + ',sym) + ^(progn (sys:rt-defv ',sym) ',sym))))) (defun expand-defun (form) (mac-param-bind form (op name args . body) form @@ -2164,7 +2166,7 @@ (defvarl %big-endian% (equal (ffi-put 1 (ffi uint32)) #b'00000001')) -(defvarl %tlo-ver% ^(6 0 ,%big-endian%)) +(defvarl %tlo-ver% ^(7 0 ,%big-endian%)) (defvarl %package-manip% '(make-package delete-package use-package unuse-package @@ -76823,6 +76823,9 @@ version 2, 3, 4 or 5, regardless of minor version. Versions 252 through 259 produce version 6.0 files and loads only version 6, regardless of minor version. +Version 260 produces version 7.0 files and loads version 6 and 7, regardless of +minor version. + .SS* Semantic Differences between Compilation and Interpretation The |