summaryrefslogtreecommitdiffstats
path: root/share
Commit message (Collapse)AuthorAgeFilesLines
...
* Adding whena macro.Kaz Kylheku2017-02-051-0/+3
| | | | | | | | | | We have ifa and conda; whena is conspicuously absent. * lisplib.c (ifa_set_entries): Add autoload entry for whena. * share/txr/stdlib/ifa.tl (whena): New macro. * txr.1: Documented whena.
* Improve diagnostic of error during place expansion.Kaz Kylheku2017-02-041-0/+3
| | | | | | | | | | | * share/txr/stdlib/place.tl (call-update-expander, call-clobber-expander, call-delete-expander): On entry into these functions, propagaet the ancestry info to the original unexpanded body, not only into the final expanded body. This way, if errors go off during the expansion of the original, the diagnostic will have access to the info. Test case: (flet ((f ())) (set (fun f) 4)). With this patch we trace to (fun 4) and its location.
* Replace sys:cp-origin with smarter function.Kaz Kylheku2017-02-041-17/+10
| | | | | | | | | | | | | | | | sys:cp-origin blindly propagates macro origin into a tree structure, and has to perform a complicated circularity check to avoid introducing cycles We replace it with a new function which looks only for invocations of the local setter, getter or deleter macros within the tree structure and sets the macro origin only into those forms. * share/txr/stdlib/place.tl (sys:cp-origin): Function removed. (sys:propagate-ancestor): New function. (call-update-expander, call-clobber-expander, call-delete-expander): Use new function.
* Dump deferred warnings when eval exception thrown.Kaz Kylheku2017-02-031-0/+1
| | | | | | | | * eval.c (eval-exception): Call uw_dump_deferred_warnings before throwing exception. The warnings could provide valuable clues about the cause of the error. * share/txr/stdlib/error.tl (compile-error): Likewise.
* Remove sys:*lisp1* hack from place expansion.Kaz Kylheku2017-02-031-24/+32
| | | | | | | | | | | | | | | | | | | | | | | | Instead of using a special variable hack to pass down the request to treat a form as Lisp-1 if it happens to be a symbol, we now wrap the form in ^(sys:l1-val ,form). We define sys:l1-val as a place. In the case when form is a symbol with no lexical binding, requiring the special Lisp-1 treatment, sys:l1-val produces ^(sys:lisp1-value, form). We define that as a place also, and that takes care of everything. * share/txr/stdlib/place.tl (sys:*lisp1*): Special variable removed. (sys:sym-update-expander, sys:sym-clobber-expander): Do not test sys:*lisp1*; just produce a sys:setq form for updating a symbolic place. (call-update-expander, call-clobber-expander, call-delete-expander): Drop the bugfix in the previous commit: re-binding of sys:*lisp1* to nil (defplace sys:l1-val, defplace sys:lisp1-value): New places. (defplace dwim): Do not bind sys:*lisp1*. Wrap obj-place in a sys:l1-val form, thereby annotating it so that it receives the right sort of place expander.
* bugfix: limit depth of Lisp-1 treatment of places.Kaz Kylheku2017-02-021-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | This underscores why sys:*lisp1* is so hacky and should be removed. When we obtain the update, clobber or delete expander of a place which is the argument of a DWIM, requiring Lisp-1 treatment, we bind the sys:*lisp1* special. This alters the behavior of obtaining an expander for a symbolic place. Unfortunately, because call-update-expander (and friends) use sys:expand, all levels of the form are subject to place expansion with sys:*lisp1* bound to t. Example: (set [(car (inc a 2)) 10] "foo") Here, the (car ...) form is the place operand of the DWIM operator, and so sys:*lisp1* is set up around getting its expander. But then, oops, the a in (inc a 2) is also treated as Lisp-1, wrongly. These changes band-aid the situation. * share/txr/stdlib/place.tl (call-udpate-expander, call-clobber-expander, call-delete-expander): After retrieving the expander, bind sys:*lisp1* to nil so that its effect does not spill over into the sys:expand call which we apply to the expansion; i.e. reset sys:*lisp1* to nil around recursive expansion so that the Lisp-1 treatment is confined to depth 1.
* Version 167.txr-167Kaz 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.
* awk: support list of string as input source.Kaz Kylheku2017-01-291-1/+4
| | | | | | | | * share/txr/stdlib/awk.tl (sys:awk-state loop): Allow an input source to be a list of strings, which is converted to a stream. * txr.1: Documented.
* catch: expand param macros before inserting arg.Kaz Kylheku2017-01-291-2/+5
| | | | | | | * share/txr/stdlib/except.tl (catch): Expand the parameters and body of each clause with sys:expand-params to get rid of parameter macros. Then insert the leftmost gensym. This now allows parameter macros to be used in cach clauses.
* Version 166.txr-166Kaz Kylheku2017-01-261-1/+1
| | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise. * txr.vim, tl.vim: Regenerated.
* awk macro: provide name of current input via fname.Kaz Kylheku2017-01-261-0/+5
| | | | | | | | | | * share/txr/stdlib/awk.tl (sys:awk-state): New slot, file-name. (sys:awk-state loop): Set file-name from current input name, or else from the stream name property if the current input is a stream object. (sys:awk-mac-let): New awk macro, fname. * txr.1: Documented fname.
* awk macro: bind *stdin* to current input stream.Kaz Kylheku2017-01-261-5/+5
| | | | | | | | * share/txr/stdlib/awk.tl (sys:awk-state loop): Instead of using the lexical variable stin, use *stdin*, so that the standard input stream is re-bound. * txr.1: Documented binding and scope of *stdin*.
* Local macrolets in build become functions.Kaz Kylheku2017-01-251-5/+5
| | | | | | | | | | * share/txr/stdlib/build.tl (sys:list-builder-macrolets): Function renamed to sys:list-builder-flets. Builds local functions instead of macrolets. (build): Follow rename of sys:list-builder-macrolets. * txr.1: Documentation updated and example added of use of add as a higher order function.
* New handle* macro, analogous to catch*.Kaz Kylheku2017-01-251-4/+12
| | | | | | | | | | | * share/txr/stdlib/except.tl (sys:expand-handle): New function. (handle): Use sys:expand-handle to expand arguments. The previously unused :whole form argument is now put to use, and correctly captured using :form rather than :whole. (handle*): New macro. * txr.1: Documented.
* New catch*, giving access to exception symbol.Kaz Kylheku2017-01-251-3/+10
| | | | | | | | | | | | | | | | | | * eval.c (op_catch): The sys:catch operator now passes the exception symbol as the first argument of each clause. This means the catch macro must be adjusted. * share/txr/stdlib/except.tl (catch): Macro now inserts a gensym dummy first argument into each clause to take the symbol passed by the sys:catch operator. (catch*): New macro, which is identical to the previous catch macro, and thus exposes the symbol passed as the first argument. * txr.1: Documented catch*. * tests/012/struct.tl: Some gensym numbers need adjusting in one test case.
* bugfix: use proper plist lookup in new :key macro.Kaz Kylheku2017-01-241-2/+2
| | | | | | | | * share/txr/stdlib/keyparams.tl (sys:extract-keys, sys:extract-keys-p): Use the brand new memp function rather than memq. memq is not correct for plist lookup because of ambiguities like (:foo :bar :bar 3) where memq retrieves (:bar :bar 3) for :bar rather than (:bar 3).
* Support keyword params via :key param list macro.Kaz Kylheku2017-01-231-0/+96
| | | | | | | | | | | | | | | | | | * eval.c (expand_param_macro): Use lisplib_try_load to retry failed parameter macro lookup, thereby supporting auto-loading of modules that define parameter macros. * lisplib.c (keyparams_set_entries, keyparams_instantiate): New static functions. (lisplib_init): Support autoloading of keyparams.tl via new functions. * share/txr/stdlib/keyparams.tl: New file. * txr.1: Documented :key param list macro. * checkman.txr: Support "Parameter list macro" documentation section type.
* Bump copyright year to 2017.Kaz Kylheku2017-01-2321-21/+21
| | | | | | | | | | | | | | | | | | | | | | | | * LICENSE, LICENSE-CYG, METALICENSE, Makefile, args.c, args.h, arith.c, arith.h, cadr.c, cadr.h, combi.c, combi.h, configure, debug.c, debug.h, eval.c, eval.h, filter.c, filter.h, ftw.c, ftw.h, gc.c, gc.h, glob.c, glob.h, hash.c, hash.h, jmp.S, lib.c, lib.h, lisplib.c, lisplib.h, match.c, match.h, parser.c, parser.h, parser.l, parser.y, rand.c, rand.h, regex.c, regex.h, signal.c, signal.h, stream.c, stream.h, struct.c, struct.h, sysif.c, sysif.h, syslog.c, syslog.h, termios.c, termios.h, txr.1, txr.c, txr.h, unwind.c, unwind.h, utf8.c, utf8.h, share/txr/stdlib/awk.tl, share/txr/stdlib/build.tl, share/txr/stdlib/cadr.tl, share/txr/stdlib/conv.tl, share/txr/stdlib/except.tl, share/txr/stdlib/getopts.tl, share/txr/stdlib/getput.tl, share/txr/stdlib/hash.tl, share/txr/stdlib/ifa.tl, share/txr/stdlib/package.tl, share/txr/stdlib/path-test.tl, share/txr/stdlib/place.tl, share/txr/stdlib/socket.tl, share/txr/stdlib/struct.tl, share/txr/stdlib/tagbody.tl, share/txr/stdlib/termios.tl, share/txr/stdlib/txr-case.tl, share/txr/stdlib/type.tl, share/txr/stdlib/with-resources.tl, share/txr/stdlib/with-stream.tl, share/txr/stdlib/yield.tl: Add 2017 to all copyright headers and strings.
* defstruct: use warning for bad baseKaz Kylheku2017-01-161-4/+4
| | | | | * share/txr/stdlib/struct.tl (defstruct): Making nonexistent base type a deferrable warning.
* defstruct uses new error reporting functions.Kaz Kylheku2017-01-161-35/+32
| | | | | | | * share/txr/stdlib/struct.tl (sys:bad-slot-syntax): Takes form argument. Uses compile-error function. (defstruct): Use modified form of sys:bad-slot-syntax and compile-error instead of throw.
* defmeth uses new error reporting.Kaz Kylheku2017-01-161-6/+9
| | | | | | | * share/txr/stdlib/struct.tl (sys:defmeth): Removing checks from here. (defmeth): Add checks here with new functions which provide location info and warning deferral/supression.
* defstruct registers tentative definition.Kaz Kylheku2017-01-161-0/+1
| | | | | * share/txr/stdlib/struct.tl (defstruct): Register the struct ame as a tentative definition.
* Functions for error reporting out of macros.Kaz Kylheku2017-01-151-0/+46
| | | | | | | | | | | | | | | | | * eval.c (eval_init): Register sys:ctx-form and sys:ctx-name intrinsics. * lisplib.c (error_set_entries, error_instantiate): New static functions. (lisplib_init): Register autoloading of error.tl via new functions. * share/txr/stdlib/error.tl: New file. * struct.c (make_struct_type): Purge deferred warnings. * unwind.c (uw_late_init): Register purge-deferred-warning intrinsic.
* Version 165.txr-165Kaz Kylheku2017-01-101-1/+1
| | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise. * txr.vim, tl.vim: Regenerated.
* New Lisp feature: param list expander.Kaz Kylheku2017-01-041-0/+34
| | | | | | | | | | | | | | | | | | | | | * eval.c (pm_table): New static variable. (expand_param_macro): New static function. (expand_params): Expand parameter list macros via expand_param_macro. (eval_init): gc-protect pm_table and initialize it. Register *param-macro* variable. * lisplib.v (pmac_set_entries, pmac_instantiate): New static functions. (lisplib_init): Register autoloading of pmac.tl via new functions. * share/txr/stdlib/pmac.tl: New file. * txr.1: Notes under defun, lambds, flet/labels and defmacro about the existence of parameter macros which add to the syntax. New Parameter List Macros section. Documented *param-macro* and define-param-expander.
* Version 164.txr-164Kaz Kylheku2017-01-011-1/+1
| | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise. * txr.vim, tl.vim: Regenerated.
* Bugfix: repeated expansion of catch unstable.Kaz Kylheku2016-12-311-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | It turns out we have a silly problem: catch is a special operator, which undergoes a macro-like expansion which alters its syntax, but uses the same operator symbol. We turn catch into a macro which expands to a sys:catch operator. * eval.c (sys_catch_s): New symbol variable. (expand_catch): Function now expands sys:catch forms without altering any syntax. (do_expand): Check for sys:catch rather than catch. Call expand_catch differently: it takes the form now instead of just the arguments, so it can return the original form if no expansion takes place. (eval_init): Initialize sys_catch_s variable. Change registration of op_catch to sys:catch symbol. * lisplib.c (except_set_entries): Add catch to the list of autoload symbols for except.tl. * share/txr/stdlib/except.tl (catch): New macro for transforming catch to sys:catch. * txr.1: Reclassify catch operator as a macro.
* New awk variable fw for fixed-width delimiting.Kaz Kylheku2016-12-261-0/+23
| | | | | | | | | | * share/txr/stdlib/awk.tl (sys:awk-state): New slots fw, fw-prev and fw-ranges. (sys:awk-state rec-to-f): New logic to handle self.fw. (sys:awk-let): New local fw symacro. * txr.1: Documented fw.
* Version 163.txr-163Kaz Kylheku2016-12-201-1/+1
| | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise. * txr.vim, tl.vim: Regenerated.
* tagbody bugfix: env not passed to expander.Kaz Kylheku2016-12-201-1/+1
| | | | | | * share/txr/stdlib/tagbody.tl (tagbody): When calling sys:expand, env was left out due to wrong parenthesis placement.
* awk macro: endpont-exclusive ranges.Kaz Kylheku2016-12-201-3/+20
| | | | | | | | | * share/txr/stdlib/awk.tl (sys:awk-mac-let): Local macro sys:rng generalized to support code generation for ranges that exclude either endpoint. Local rng macro adjusted to target this new form. Local macros rng-, -rng, and -rng- added. * txr.1: Documented.
* Adding prog and prog* macros.Kaz Kylheku2016-12-131-0/+9
| | | | | | | | | * lisplib.c (tagbody_set_entries): Add prog and prog* to autoload list. * share/txr/stdlib/tagbody.tl (prog, prog*): New macros. * txr.1: Documented.
* Version 162.txr-162Kaz Kylheku2016-12-071-1/+1
| | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise. * txr.vim, tl.vim: Regenerated.
* Awk macro prn becomes function.Kaz Kylheku2016-12-011-39/+47
| | | | | | | | | | | | | | | | | | | | * share/txr/stdlib/awk.tl (sys:awk-let): Renamed to sys:awk-mac-let. Macrolet prn removed from here. (sys:awk-fun-let): New macro, provides awk functions. The prn function removed from sys:awk-mac-let is generated here. (sys:awk-fun-shadowing-env): New function. (awk): Follow rename of sys:awk-let. When expanding p-action forms, use only sys:awk-mac-let; do not include the awk functions, which do not "vaporize" unlike local macros. To compensate for not including the functions, extend the macro environment with one that shadows the functions, so that during this expansion, any global macros of the same name as awk local functions are properlly hidden. In the final expansion, include the awk functions. * txr.1: Updated documentation to consistently call prn an awk function everywhere.
* bugfix: previous loop elision fix in awk.Kaz Kylheku2016-12-011-1/+2
| | | | | | | | | | * share/txr/stdlib/awk.tl (awk): We must generate the code to bind the awk-fun under the same conditions that control whether the loop call is generated to which it is an argument. Otherwise we end up with an unbound var reference: the loop isn't elided because begin/end actions are present, but the call refers to a nonexistent variable.
* bugfix: awk must consume *args*.Kaz Kylheku2016-11-291-1/+2
| | | | | | | | | | | | | | | | | | | | | | This problem happens when awk is issued from the command line followed by one or more arguments as exemplified by the usage txr -e '(awk ...) arg ... . In this case, after awk processes the args as input sources and completes, TXR resumes processing the command line arguments and wants to open arg as a script file! To address this problem, when awk defaults on using *args* as input sources, it consumes *args* by clearing the variable to nil. TXR's command line processing already reacts to changes in *args* by evaluated forms. Code that wants *args* to be left alone by awk can explicitly pass them in using (awk (:inputs *args*) ...). * share/txr/stdlib/awk.tl (sys:awk-state): Move default initialization of inputs into :postinit. If there are no inputs by :postinit time, then take *args* or *stdin*. If *args* is used in this default manner, then consume *args*. * txr.1: Documented.
* bugfix: awk elides loop despite begin/end clauses.Kaz Kylheku2016-11-291-1/+2
| | | | | | | | * share/txr/stdlib/awk.tl (awk): The macro must not elide the processing loop if there are :begin-file, :end-file or :end actions. All these actions must be missing, not only the, cond-actions for that elision to be valid.
* conformance: handle macro wrong clause syntax.Kaz Kylheku2016-11-291-1/+4
| | | | | | | | | | | | | | | | Contrary to the documentation, handle doesn't in fact have the same syntax as catch. It passes the exception symbol to clauses as the leftmost argument, followed by the exception arguments, whereas catch passes only the exception arguments. * share/txr/stdlib/except.tl (handle): Do not pass the exception sybmol as the leftmost argument, unless operating in TXR 161 or earlier compatibility. * tests/012/except.tl: drop exception symbol argument from handle clause. * txr.1: Compatibility note added.
* Awk: assignment to f doesn't yield new value.Kaz Kylheku2016-11-291-2/+2
| | | | | | * share/txr/stdlib/struct.tl (sys:rslotset): Return the new value that comes out of slotset, rather than the value of the method call. Also, we don't need macro-time wrapping.
* Version 161.txr-161Kaz Kylheku2016-11-271-1/+1
| | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise.
* bugfix: awk macro spews warnings.Kaz Kylheku2016-11-281-8/+5
| | | | | | | | | | | | | | Rather than fix this in the awk macro, let's just have sys:expand block warnings. * eval.c (warning_continue, no_warn_expand): New static function. (eval_init): Change registration of sys:expand to point to no_warn_expand. * share/txr/stdlib/place.tl (call-update-expander, call-clobber-expander, call-delete-expander, sys:placelet-1): Remove ignwarn wrapping from sys:expand calls.
* Version 160.txr-160Kaz Kylheku2016-11-271-1/+1
| | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise. * txr.vim, tl.vim: Regenerated.
* Warn about unbound functions.Kaz Kylheku2016-11-271-20/+21
| | | | | | | | | | | | | | * eval.c (do_expand): If a compound form doesn't expand into anything, then let us check whether it calls an unbound function, and issue a warning. * share/txr/stdlib/place.tl (sys:pl-expand): Move function definition ahead of first use to suppress unbound function warning. Eventually we will have a relaxed model of deferred warning about this. (sys:placelet-1): Suppress warnings around call to sys:expand because we are expanding a body into which we inserted function calls without inserting their definitions.
* Expander warns about unbound variables.Kaz Kylheku2016-11-262-3/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * eval.c (eval_exception): New static function. (eval_error): Reduced to wrapper around eval_exception. (eval_warn): New function. (me_op): Bind the rest symbol in a shadowing env to suppress watnings about unbound rest. (do_expand): Throw a warning when a bindable symbol is traversed that has no binding. (expand): Don't install atoms as last_form_expanded. * lib.c (warning_s, restart_s, continue_s): New symbol variables. (obj_init): Initialize new symbol variables. * lib.h (warning_s, restart_s, continue_s): Declared. * lisplib.c (except_set_entries): New entries for ignwarn and macro-time-ignwarn. * parser.c (repl_warning): New static function. (repl): Use repl_warning function as a handler for warning exceptions: to print their message and then continue by throwing a continue exception. * parser.y (warning_continue): New static function. (parse_once): Use warning_continue to ignore warnings. In other words, we suppress warnings from Lisp that is mixed into TXR pattern language code, because this produces too many false positives. * share/txr/stdlib/except.tl (ignwarn, macro-time-ignwarn): New macros. * share/txr/stdlib/place.tl (call-update-expander, call-clobber-expander, call-delete-expander): Ignore warnings around calls to sys:expand, because of some gensym-related false positives (we expand code into which we inserted some gensyms, without having inserted the constructs which bind them. * tests/011/macros-2.txr: Suppress unbound variable warnings from a test case. * tests/012/ifa.tl: Bind unbound x y variables in one test case. * tests/012/struct.tl: Suppress unbound variable warnings in some test cases. * uwind.c (uw_throw): If a warning is unhandled, then print its message with a "warning" prefix and then throw a continue exception. (uw_register_subtype): Eliminate the check for sub already being a subtype of sup. This allows us to officially register new types against t. (uw_late_init): Register continue exception type as a subtype of the restart type. Formally register warning type. * txr.1: Documented ignwarn.
* bugfix: unbound var in IP-slash-notation functions.Kaz Kylheku2016-11-251-6/+6
| | | | | | * share/txr/stdlib/socket.tl (sys:str-inaddr-net-impl): Use let* so that calculation of we can see dependent w variable.
* bugfix: broken test-inc macro.Kaz Kylheku2016-11-241-1/+1
| | | | | * share/txr/stdlib/place.tl (test-inc): Expander refers to unbound variable.
* Version 159.txr-159Kaz Kylheku2016-11-211-1/+1
| | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise. * txr.vim, tl.vim: Regenerated.
* Diagnose undefined functions in trace.Kaz Kylheku2016-11-191-1/+3
| | | | | | | | | * share/txr/stdlib/trace.tl (sys:trace): If symbol-function returns nil, throw exception. * txr.1: Document the behavior, along with return values of trace and untrace, and the tolerance of untrace to bad arguments.
* Allow global macros to be denoted by (macro sym).Kaz Kylheku2016-11-191-0/+8
| | | | | | | | | | | | | | | | | In this patch we allow (symbol-function '(macro sym)), (defun (macro sym) (form env) ...), and (trace (macro sym)). * eval.c (macro_s): New symbol variable. (lookup_fun, func_get_name, op_defun): Support (macro sym) syntax. (builtin_reject_test): Pass through (macro sym) syntax. (eval_init); Initialize macro_s. * share/txr/stdlib/place.tl (sys:get-fun-getter-setter): Support macro place. * txr.1: Documented verything.
* Bugfix: cannot untrace individual method.Kaz Kylheku2016-11-191-1/+1
| | | | | * share/txr/stdlib/trace.tl (sys:*trace-hash*): Hash must be equal-based to correctly support compound places.