summaryrefslogtreecommitdiffstats
path: root/share
Commit message (Collapse)AuthorAgeFilesLines
...
* trace: allow format and * functions to be traced.Kaz Kylheku2017-07-161-2/+5
| | | | | | | | * share/txr/stdlib/trace.tl (sys:tr*, sys:trfm): New variables, holding the * and format functions. (sys:trace-enter, sys:trace-leave): Use format and * through the aliases, so we don't trigger infinite recursion if these are traced.
* Remove unused variable in placelet implementation.Kaz Kylheku2017-07-151-1/+1
| | | | | * share/txr/stdlib/place.tl (sys:placelet-1): Remove the genyms called steal-getter which is not referenced.
* Version 182.txr-182Kaz Kylheku2017-07-091-1/+1
| | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise. * txr.vim, tl.vim, protsym.c: Regenerated.
* places: remove superfluous @1.Kaz Kylheku2017-07-091-2/+2
| | | | | | * share/txr/stdlib/place.tl (sys:get:fun-getter-setter): Remove superfluous @1 from op macro syntax, on the basis that (op function @1) is equivalent to (op function).
* structs: improve access to initfun and postinitfun.Kaz Kylheku2017-07-092-3/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In this change, a struct type's initfun and postinitfun become mutable. This is achieved by modeling them as the pseudo-static-slots :initfun and :postinitfun. Effectively these now behave as reserved names which do not denote static slots but these special functions. * eval.c (lookup_fun): When (meth type slot) syntax is encountered, treat the slot names :init and :postinit specially: retrieve these special functions instead of accessing static slots. * share/txr/stdlib/place.tl (sys:get-fun-getter-setter): Similarly, when handling (meth type slot) syntax, return the alternative getter/setter functions for the special functions, not the static slot accessing functions. Also, getting rid of a useless @1 here in existing code, since (op foo @1) is equivalent to (op foo). * share/txr/stdlib/struct.tl (sys:defmeth): Check for the special names :init and :postinit, handling these through the appropriate setter functions rather than static-slot-ensure. * struct.c (init_k, postinit_k): New keyword symbol variables. (struct_init): Initialize init_k and postinit_k. Register intrinsics struct-get-initfun, struct-set-initfun, struct-get-postinitfun and struct-set-postinitfun. * (struct_get_initfun, struct_set_initfun, struct_get_postinitfun, struct_set_postinitfun): New functions. (method_name): For each struct type visited, check whether the function is the initfun or postinitfun and return the appropriate meth syntax if so. * struct.h (init_k, postinit_k, struct_get_initfun, struct_set_initfun, struct_get_postinitfun, struct_set_postinitfun): Declared. * txr.1: Documented. Updated description of method-name, defmeth, and documented new functions.
* ffi: new make-zstruct function and znew macro.Kaz Kylheku2017-07-021-0/+7
| | | | | | | | | | | | | * ffi.c (make_zstruct): New function. (ffi_init): Register make-zstruct instrinsic. * ffi.h (make_zstruct): Declared. * lisplib.c (ffi_set_entries): Add znew to autload list. * share/txr/stdlib/ffi.tl (znew): New macro. * txr.1: Documented make-zstruct and znew.
* Version 181.txr-181Kaz Kylheku2017-07-011-1/+1
| | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise. * txr.vim, tl.vim, protsym.c: Regenerated.
* ffi: new macro, deffi-sym.Kaz Kylheku2017-06-261-0/+12
| | | | | | | | * lisplib.c (ffi_set_entries): Add deffi-sym to autload list. * share/txr/stdlib/ffi.tl (deffi-sym): New macro. * txr.1: Documented.
* Version 180.txr-180Kaz Kylheku2017-06-251-1/+1
| | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise. * txr.vim, tl.vim, protsym.c: Regenerated.
* awk macro: bugfix: non-use of redirection mode strings.Kaz Kylheku2017-06-191-5/+3
| | | | | | | | | | | | | | | | The problem here is that ensure-stream ignores the mode argument and decides between "r" and "w". That is incorrect; the mode could be "a" for append. The second problem is that the ignored mode strings are also wrong. For an input pipe, "w" is specified rather than "r". * share/txr/stdlib/awk.tl (sys:awk-state ensure-stream): Use the mode argument. The cases consolidate, because all that need be distinguished here is file versus pipe. (sys:awk-mac-let): for the <! redirection (input from pipe), the mode must be "r", not "w".
* awk macro: bugfix: :output file stream not closed.Kaz Kylheku2017-06-191-1/+3
| | | | | | | | | | | | | | | | | | In the case when the :output clause of the awk macro opens a stream, it isn't closing it. Why don't we treat such a stream uniformly with redirections. * share/txr/stdlib/awk.tl (sys:awk-state :postinit): If a file is opened for output, then don't just install this file as self.output. Also place it into the self.streams hash, identified by using the key (:outf <name>), just like a (-> "name") redirection. This ensures that it will be closed when the awk macro terminates. It's also potentially useful in that output redirections referring to the name will use the same stream. * txr.1: Documented that streams opened by :output are closed, and that they are treated uniformly with redirections.
* Version 179.txr-179Kaz Kylheku2017-06-181-1/+1
| | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise. * txr.vim, tl.vim, protsym.c: Regenerated.
* ffi: turn carray-sub into accessor.Kaz Kylheku2017-06-131-0/+3
| | | | | | | | | | | | | | | | * lisplib.c (ffi_set_entries): Register carray-sub for autoload. * share/txr/stdlib/ffi.tl (carray-sub): New place macro, aliases to sub. This is not 100% correct since that means it will admit non-carray objects, but the alternative is to clone the entire sub expander with a few changes, or else factor out sub expansion into a shared routine. Bleh ... * txr.1: Documented. We don't cover up the ruse we perpetrated, and reveal that it's just a place macro targetting sub.
* bugfix: autoload syntactic places.Kaz Kylheku2017-06-131-2/+6
| | | | | | | | | | | | | | | | | | | | | | | TXR Lisp doesn't autoload the definition of places. For instance if a (set (foo x) y) appears out of the blue and foo is keyed for autoload, it doesn't happen. The right place to fix this is to do the autload check in the place macro expander, since every place form is tried as a macro. We need to expose the lisplib_try_load function as a Lisp intrinsic. * lisplib.c (lisplib_init): Register sys:try-load intrinsic, mapped to lisplib_try_load. * share/txr/stdlib/place.tl (sys:get-place-macro): New function. (sys:pl-expand): Use sys:get-place-macro instead of direct lookup in *place-macro* hash. The new function tries to autoload the symbol if it finds no place macro for it.
* Version 178.txr-178Kaz Kylheku2017-06-121-1/+1
| | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise. * txr.vim, tl.vim, protsym.c: Regenerated.
* awk macro: new fconv conversions c and cz.Kaz Kylheku2017-06-121-0/+4
| | | | | | | | | | * share/txr/stdlib/conv.tl (sys:conv-let): New local functions c and cz, using the new #\c radix conversion. * txr.1: Documented new extension under the fconv awk macro. Also fixed a typo here; the b conversion was exemplified as (c str).
* awk macro: fix broken rng.Kaz Kylheku2017-06-071-9/+15
| | | | | | | | | | | | | | | Bug: rng fails to activate when the to and from condition are true for the same record. * share/txr/stdlib/awk.tl (sys:awk-mac-let): Rename the flag-new gensym holder to flag-act, since it indicates whether the range is active, either from before or due to being activated by the current record. A new gensym is added to indicate whether the range is being deactivated in this record. The inclusive rng range refers to this variable rather than flag-old. But a bug emulation is provided to refer to the wrong variable. * txr.1: Added compatibility note.
* Version 177.txr-177Kaz Kylheku2017-06-071-1/+1
| | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise. * txr.vim, tl.vim, protsym.c: Regenerated.
* ffi: functions and macros for basic type properties.Kaz Kylheku2017-06-021-0/+15
| | | | | | | | | | | | | | | | | | * ffi.c (ffi_alignof, ffi_offsetof, ffi_arraysize, ffi_elemsize, ffi_elemtype): New functions. (ffi_init): Registered intrinsics ffi-alignof, ffi-offsetof, ffi-arraysize, ffi-elemsize, ffi-elemtype. * ffi.h (ffi_alignof, ffi_offsetof, ffi_arraysize, ffi_elemsize, ffi_elemtype): Declared. * lisplib.c (ffi_set_entries): New autoload entries alignof, offsetof, arraysize, elemsize, elemtype. * share/txr/stdlib/ffi.tl (alignof, offsetof, arraysize, elemsize, elemtype): New macros. * txr.1: Documented new functions and macros.
* Version 176.txr-176Kaz Kylheku2017-05-211-1/+1
| | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise. * txr.vim, tl.vim, protsym.c: Regenerated.
* ffi: new macro, deffi-var.Kaz Kylheku2017-05-201-0/+15
| | | | | | | | * lisplib.c (ffi_set_entries): Autload entry for "deffi-var". * share/txr/stdlib/ffi.tl (deffi-var): New macro. * txr.1: Documented.
* ffi: deffi generates fixed-arg defun.Kaz Kylheku2017-05-201-10/+10
| | | | | | | * share/txr/stdlib/ffi.tl (deffi): Since the arity of a foreign function is fixed, generate a fixed-argument defun. This provides a better check on the number of arguments than letting ffi-call detect it.
* ffi: overhaul ffi-call API and document it.Kaz Kylheku2017-05-201-1/+1
| | | | | | | | | | | | | | | * ffi.c (ffi_call_wrap): Take struct args * parameters rather than a list. Check that number of arguments matches required number from call desc. No need to build argument array any more; we just refer to the one in args. Also, the first two parameters are reversed for consistency with other functions. (ffi_init): Update registration of ffi-call to reflect type change. * ffi.h (ffi_call_wrap): Declaration updated. * txr.1: Documented ffi-call.
* ffi: turn carray-ref into accessor.Kaz Kylheku2017-05-201-0/+2
| | | | | | | | | | * lisplib.c (ffi_set_entries): Add carray-ref to list of autoload names. * share/txr/stdlib/ffi.tl (carray-ref, carray-refset): Registered function pair as a simple accessor. * txr.1: Updated carray-ref doc.
* awk: new feature: again operator.Kaz Kylheku2017-05-191-3/+3
| | | | | | | | | | | | | * share/txr/stdlib/awk.tl (sys:awk-state loop): Wrap a loop around around the two forms that split the record into fields and dispatch the main rule function. The loop repeats if the named block returns :awk-again. (sys:awk-mac-let): New local macro (again) which bails out of the :awk-rec block just like (next) does, but specifies :awk-again as the return value. * txr.1: Documented.
* ffi: macro named ffi for type compiling shorthand.Kaz Kylheku2017-05-171-0/+3
| | | | | | | | | * lisplib.c (ffi_set_entries): Add "ffi" to autoload name list. * share/txr/stdlib/ffi.tl (ffi): New macro. * txr.1: Documented.
* ffi: typedef macro instead of deffi-type.Kaz Kylheku2017-05-171-0/+3
| | | | | | | | | | * share/txr/stdlib/ffi.tl (typedef): New macro. * lisplib.c (ffi_set_entries): Add typedef to autoload name list. * txr.1: Doc update. Remove mentions of deffi-type, though it continues to work.
* Version 175.txr-175Kaz Kylheku2017-05-151-1/+1
| | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise. * txr.vim, tl.vim, protsym.c: Regenerated.
* ffi: support programmable abort return value.Kaz Kylheku2017-05-111-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | | * ffi.c (stuct txr_ffi_closure): New member, abort_retval. (ffi_closure_mark_op): Mark the new member. (ffi_closure_dispatch_safe): Implement the abort_retval. If it is not nil, use put to place the value into the return buffer. There is a risk that this could also throw an exception, which is no longer protected: programer's problem. (ffi_make_closure): New abort_ret_in argument, which is defaulted and stored. (ffi_init): Update registration of ffi-make-closure to reflect new argument. * ffi.h (ffi_make_closure): Declaration updated. * share/txr/stdlib/ffi.tl (sys:deffi-cb-expander): Add abort-retval parameter; insert into ffi-make-closure call. (deffi-cb): Take optional abort-retval expression; pass it down to the expander function. (deffi-cb-unsafe): Pass nil as abort-retval down to expander. * txr.1: Documented.
* ffi: a measure of safety for callbacks.Kaz Kylheku2017-05-111-10/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We don't want, by default, for callbacks to capture delimited continuations across foreign code, or perpetrate non-local transfers across foreign code. Here, we take an approach similar for what was done in ftw_wrap. * ffi.c (s_exit_point): New global variable with internal linkage. (ffi_call_wrap): If s_exit_point isn't nil, then it means that the callback intercepted a nonlocal transfer and stored its exit point. We resume the transfer to that exit point instead of returning normally. (ffi_closure_dispatch_safe): New static function. (ffi_make_closure): Support a new argument which indicates whether to make a closure which uses ffi_closure_dispatch_safe, or ffi_closure_dispatch. (ffi_init): Update registration of ffi-make-closure intrinsic. * ffi.h (ffi_make_closure): Declaration updated. * share/txr/stdlib/ffi.tl (sys:deffi-cb-expander): New function. (deffi-cb): Macro internals replaced by call to new function. (deffi-cb-safe): New macro. * txr.1: Documentation of ffi-make-closure updated. New deffi-cb-unsafe macro documented.
* ffi: add macro language.Kaz Kylheku2017-05-061-0/+91
| | | | | | | | * lisplib.c (ffi_set_entries, ffi_instantiate): New static functions. (lisplib_init): Register auto-loading of ffi.tl. * share/txr/stdlib/ffi.tl: New file.
* structs: check existence of type in new and lnew.Kaz Kylheku2017-05-041-9/+23
| | | | | | | | | | | | | | | | | | | | | This achieves two objectives. The obvious one is that we get a diagnostic for new expressions that name a nonexistent type, due to a typo, before those expressions are executed. However, this also fixes an annoying issue: spurious warnings about nonexistent slots, related to structs which have not yet been autoloaded. A test case for this is an expression like (let ((b (new list-builder))) b.(add 42)). Because list-builder is auto-loaded, the add slot doesn't exist. But (new list-builder) doesn't trigger that auto-load; so the deferred warning about the nonexistent slot isn't suppressed. With this change, the existence check in (new list-builder) will trigger the auto-load for the module which defines list-builder, causing the add slot to exist before the b.(add 42) expression is visited by the expander. * share/txr/stdlib/struct.tl (sys:check-struct): New function. (new, lnew): Issue warning if the type doesn't exist.
* Bugfix: incorrect substitution in suspend macro.Kaz Kylheku2017-04-151-1/+1
| | | | | | * share/txr/stdlib/yield.tl (suspend): The body forms must be inserted into a progn, because sys:abscond-from just takes one optional value to evaluate.
* Version 174.txr-174Kaz Kylheku2017-04-041-1/+1
| | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise. * txr.vim, tl.vim: Regenerated.
* Version 173.txr-173Kaz Kylheku2017-03-251-1/+1
| | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise. * txr.vim, tl.vim: Regenerated.
* termios: broken go-cbreak method.Kaz Kylheku2017-03-251-1/+1
| | | | | * share/txr/stdlib/termios.tl (termios go-raw): Fix call to nonexistent method.
* trace: wrong function printed in traces.Kaz Kylheku2017-03-241-3/+4
| | | | | | | | | | | | When tracing for two or more functions is enabled in a single trace form, the the function tracing hooks print the wrong name for all but the rightmost function. * share/txr/stdlib/trace.tl (sys:trace): Fix code which assumes that the each operator binds fresh lexical variables on each iteration. Bind a fresh lexical variable lex-n which copies the current value of the loop variable n, and refer to this lexical out of the tracing lambda.
* Warn when a nonexistent slot is referenced.Kaz Kylheku2017-03-231-8/+33
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Implementing warning for the situaton when the qref, uref, usl and umeth macro operators are asked to refer to a slot that doesn't exist in any struct type. This won't catch errors referencing a slot on the wrong type, but it will catch slots that are misspelled in such a way that the typo doesn't land on any slot. * share/txr/stdlib/struct.tl (defstruct): Register tenative slot definitions for all slots to nuke warnings. (sys:check-slot): New function. (qref, usl, umeth): Check slots with sys:check-slot. (uref): Drop :whole argument, which is unused. (defmeth): Register tentative definition for slot. * struct.c (slot_s, static_slot_s): New symbol variables. (slot_type_hash, static_slot_type_hash): New hash tables, associating symbols with lists of struct type names in which they are defined. (struct_init): Initialize and gc-protect hashes. Initialize new symbols, interning in system package. Register new intrinsic funtions sys:slot-types and sys:static-slot-types. (make_struct_type): Register slots in new hashes. (static_slot_ens_rec): Register new slow in static slot hash. (slot_types, static_slot_types): New functions, registered as intrinsics. (slot_type_reg, static_slot_type_reg): New functions. * struct.h (print_s): Declared. (slot_s, static_slot_s): Declared. (slot_types, static_slot_types, slot_type_reg, static_slot_type_reg): Declared.
* Version 172.txr-172Kaz Kylheku2017-03-191-1/+1
| | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise. * txr.vim, tl.vim: Regenerated.
* trace: implement redefinition checks.Kaz Kylheku2017-03-171-0/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | The tracing module should warn when traced functions or methods are being redefined, and stop tracing the original methods. * eval.c (trace_check): New function. Calls sys:trace-redefined-check if the trace module has been loaded, otherwise does nothing. (op_defun, op_defmacro): Call trace_check to have a warning issued for a redefined traced function or macro. * eval.h (trace_check): Declared. * lisplib.c (trace_loaded): New global variable. (trace_instantiate): Flip trace_loaded to t. * lisplib.h (trace_loaded): Declared. * share/txr/stdlib/trace.tl (sys:trace-redefine-check): New function. Checks two situations: traced function or method is redefined (neither old nor new is traced any longer), and traced method is overridden (base method continues to be traced, override is not traced). * struct.c (static_slot_ensure): Do a trace check here, taking care of defmeth.
* trace: detect inheritance, change name and warn.Kaz Kylheku2017-03-171-10/+32
| | | | | | | | | | | | When a method is traced that is actually derived from another struct type, we convert the (meth ...) name to refer to that type and issue a warning. * share/txr/stdlib/trace.tl (sys:trace-canonicalize-name): New function. (sys:trace): Canonicalize name, and trace the canonicalized name. Warn if it is different from the original name. (sys:untrace): Likewise for untracing.
* Version 171.txr-171Kaz Kylheku2017-03-141-1/+1
| | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise. * txr.vim, tl.vim: Regenerated.
* uref: the a.b.c syntax extended to .a.b.cKaz Kylheku2017-03-061-0/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Now it is possible to use a leading dot on the referencing dot syntax. This is the is the "unbound reference dot". It expands to the uref macro, which denotes an unbound-reference: it produces a function which takes an object as the argument, and curries the reference implied by the remaining arguments. * eval.c (uref_s): New global symbol variable. (eval_init): Intern uref symbol and init uref_s. * eval.h (uref_s): Declared. * lib.c (simple_qref_args_p): A qref expression is now also not simple if it contains an embedded uref, meaning that it cannot be rendered into the dot notation without ambiguity. (obj_print_impl): Support printing (uref a b c) as .a.b.c. * lisplib.c (struct_set_entries): Add uref to the list of autoload triggers for struct.tl. * parser.l (DOTDOT): Consume any leading whitespace as part of recognizing the DOTDOT token. Otherwise the new rule for UREFDOT, which matches (mandatory) leading space will take precedence, causing " .." to be scanned wrong. (UREFDOT): Rule for new kind of dot token, which is preceded by mandatory whitespace, and isn't consing dot (which has mandatory trailing whitespace too, matched by an earlier rule). * parser.y (UREFDOT): New token type. (i_dot_expr, n_dot_expr): New grammar rules. (list): Handle a leading dot on the first element of a list as a special case. Things are done this way because trying to work a UREFDOT into the grammar otherwise causes intractable conflicts. (i_expr): The ^, ' and , punctuators are now followed by an i_dot_expr, so that the expression can be an unbound dot. (n_expr): Same change as in i_expr, but using n_dot_expr. Plus new UREFDOT n_expr production. * share/txr/stdlib/struct.tl (uref): New macro. * txr.1: Documented.
* Version 170.txr-170Kaz Kylheku2017-02-281-1/+1
| | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise. * txr.vim, tl.vim: Regenerated.
* Version 169.txr-169Kaz Kylheku2017-02-111-1/+1
| | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise. * txr.vim, tl.vim: Regenerated.
* Use non-hacky representation for deferrable warnings.Kaz Kylheku2017-02-101-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Deferrable warnings now get their own subtype, defr-warning. The tag is a regular argument: no funny dotted argument list. * eval.c (eval_defr_warn): Throw new style deferrable warning. (me_op, no_warn_expand): Catch defr-warning rather than warning. Use uw_muffle_warning to suppress it. (gather_free_refs): Parse new representation of deferrable warning. (expand_with_free_refs): Catch defr-warning rather than warning. * lib.c (defr_warning_s): New symbol variable defined. (obj_init): Initialize defr_warning_s. * lib.h (defr_warning_s): Declared. * share/txr/stdlib/error.tl (compile-defr-warning): Throw new-style deferrable warning. * unwind.c (uw_muffle_deferrable_warning): Function removed. (uw_throw): Bugfix: handle warnings by checking by subtype rather than exactly for the warning type. Distinguish deferrable warnings by subtype rather than argument list shape. (uw_defer_warning): Take the new style args and reconstruct the (msg . tag) representation for a deferred warning, so the other functions don't have to change. (uw_late_init): Register defr-warning as exception subtype of warning. * unwind.h (uw_muffle_deferrable_warning): Decl removed. * txr.1: Adjusted all documentation touching on the subject of the representation of deferrable warnings.
* awk macro: warn about invalid function use in rng.Kaz Kylheku2017-02-101-11/+26
| | | | | | | | | | | | | Improving the new feature to handle functions also, and improve the diagnostic by reporting the specific to or from subform of which contains the reference. * share/txr/stdlib/awk.tl (sys:awk-code-move-check): Take a an argument indicating the kinds of bindings being checked, symbols or functions, and an extra form argument. (sys:awk-mac-let): Pass new arguments to sys:awk-code-move-check and also call it two more times to report on functions also.
* awk macro: warn about invalid var use in rng forms.Kaz Kylheku2017-02-091-30/+50
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The awk macro abruptly relocates rng forms out of their apparent scope. Therefore, code like this is wrong: (awk ((let ((x t)) (rng t x)) (action))) The rng form is transformed and relocated to a scope in which the let is not visible. This is a problem worth warning about. In the above case, there will also be a warning about the variable x being unbound, which might alerts the programmer to the problem. However, in cases where there is yet another binding of x introduced via :let or outside of awk, that warning wll not occur: the code motion will silently cause x to refer to the wrong x: (awk (:let (x nil)) ((let ((x t)) (rng 1 x)) ;; refers to the (x nil) binding!!! (action))) (let ((x nil)) (awk ((let ((x t)) (rng 1 x)) ;; refers to the (x 4) binding!!! (action)))) Now there is a warning for this situation. * share/txr/stdlib/awk.tl (sys:awk-compile-time): New slot, outer-env. (sys:awk-expander): Takes an env parameter, which is stored into the new slot of the awk-compile-time structure. (sys:awk-code-move-check): New function. (sys:awk-mac-let): Use sys:expand-with-free-refs to expand the rng forms, capturing the extra information which enables the implementation of the warning. The rng variants are refactored to pass the original form to the sys:rng expander. This allows the diagnostic to display the original rng form. (awk): Parameter e renamed to outer-env, and passed to sys:awk-expander.
* bugfix: no restart catch in compile-warning.Kaz Kylheku2017-02-091-1/+3
| | | | | | * share/txr/stdlib/error.tl (compile-warning): Wrap throw in a catch with a continue handler to properly implement the warning protocol.
* Version 168.txr-168Kaz Kylheku2017-02-021-1/+1
| | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise. * txr.vim, tl.vim: Regenerated.