summaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
...
* Adding whena macro.Kaz Kylheku2017-02-053-1/+23
| | | | | | | | | | 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.
* bugfix: wrongly strict stream class check in poll.Kaz Kylheku2017-02-051-1/+1
| | | | | | | * sysif.c (poll_wrap): Fix function not accepting streams of type stdio-stream or any other derived stream type. We must check that the object is subtyped from stream, not that it's exactly of type stream.
* keep/remove: reduce duplication, optimize.Kaz Kylheku2017-02-052-138/+136
| | | | | | | | | | | * lib.c (rem_impl): New static function. (remove_if): Rewritten similarly to rem_impl. (remq, remql, remqual, keepq, keepql, keepqual): Reduced to wrappers around rem_impl. (keep_if): Wrapper around remove_if with test negated. * lib.c (remq, remql, remqual, remove_if, keepq, keepql, keepqual, keep_if): Argument names adjusted.
* bugfix: incorrect keepql due to spurious statement.Kaz Kylheku2017-02-051-1/+0
| | | | * lib.c (keepql): Remove repeated list_collect_nconc call.
* Expose rlcp_tree function.Kaz Kylheku2017-02-042-2/+29
| | | | | | | * eval.c (eval_init): Register rlcp-tree intrinsic. * txr.1: Documented rlcp-tree. Also documented that rlcp doesn't overwrite location info.
* Add useful sys:bits function.Kaz Kylheku2017-02-041-0/+8
| | | | | | | | | | | | | | | | | | sys:bits converts a Lisp value to an integer whose value is the object's bit pattern interpreted as a pure binary number. (Only the "unboxed" part of the object that is stored in variables or passed into functions, not any "boxded" heap part which is referenced.) this holds: (eq a b) <--> (= (sys:bits a) (sys:bits b)) Two values a and b are the same object iff their sys:bits values are the same integer. * arith.c (bits): New static function. (arith_init): Register bits as sys:bits.
* doc: typo under hidden sym.Kaz Kylheku2017-02-041-1/+1
| | | | | * txr.1: "sane name" -> "same name". We need aspell to grok semantics.
* bugfix: rehome_sym not removing from hidden list.Kaz Kylheku2017-02-041-0/+1
| | | | | | | | * lib.c (rehome_sym): Remove a symbol of the same name as sym from the target package's hidden symbol list. The documentation says that this is done. Basically, rehome_sym permanently brings in a symbol, so that a same-named symbol is kicked out.
* bugfix: don't print unnecessary package prefix.Kaz Kylheku2017-02-041-2/+2
| | | | | | | | * lib.c (symbol_visible): Fix wrong accesses to hash table cell: the symbol is in the cdr, not car. This bug means that any symbol which is not in the package is declared not visible and thus requires a package prefix.
* 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.
* bugfix: "expansion at nil" in error trace.Kaz Kylheku2017-02-031-1/+1
| | | | | * eval.c (error_trace): Wrong variable was checked as basis for selecting one of two variants of diagnostic.
* Dump deferred warnings when eval exception thrown.Kaz Kylheku2017-02-032-0/+3
| | | | | | | | * 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.
* Expand sys:setqf separately, with better accuracy.Kaz Kylheku2017-02-031-1/+25
| | | | | | | * eval.c (expand_setqf): New static function. (do_expand): Handle sys:setqf via new function, which avoids expanding the symbol, checks that it isn't a lexical function, and warns about an unbound function.
* Forbid lexical function mutation.Kaz Kylheku2017-02-031-1/+39
| | | | | | | | | | | * eval.c (expand_lisp1_setq): New static function. (op_setqf): Check that the function binding which was found is the global one. If not, throw an error that lexical functions can't be mutated. (do_expand): Handle sys:lisp1-setq operator expansion seprately from the other setq operators, via the new function, which enforces an expansion-time check against mutation of lexical functions.
* Expander check for macro destination in setq forms.Kaz Kylheku2017-02-031-0/+4
| | | | | * eval.c (do_expand): Throw an error if the destination is a symbol macro which requires expanding.
* When expanding sys:lisp1-value, check for bad form.Kaz Kylheku2017-02-031-1/+5
| | | | | * eval.c (expand_lisp1_value): If the first argument is an object other than a bindable symbol, throw an error.
* More accurate error wording from Lisp-1 operators.Kaz Kylheku2017-02-031-2/+2
| | | | | | | * eval.c (op_lisp1_setq, op_lisp1_value): If a Lisp-1 binding is not found, this is because it is neither a function nor variable, not because it is not a variable. The error message now reflects this.
* 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-026-590/+633
| | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise. * txr.vim, tl.vim: Regenerated.
* parser: diagnose run-on symbols.Kaz Kylheku2017-02-011-0/+14
| | | | | | | | | | * parser.l (grammar): Add rules which capture two symbols glued together, and diagnose as bad token. Of course a legitimate symbol token can be divided into two that are glued together. This rule is placed after the legitimate symbol matching rule, so that if a token can be interpreted as a single symbol token or as two, the first interpretation is taken.
* parser: diagnose more kinds of junk after float.Kaz Kylheku2017-02-011-1/+2
| | | | | | | | | * parser.l (grammar): Add a rule that if a floating-point (of the type that ends in decimal digits with an optional exponent) is immediately followed by a period which is not followed by another period (range syntax), it is trailing junk. For instance 1.0.3 or .2.$, or 1.0. followed by no other input.
* Suppress undef warnings in command line file.Kaz Kylheku2017-01-291-0/+3
| | | | | | * txr.c (txr_main): Bind sys:*load-recursive* to t before reading and evaluating forms, then bind to nil before entering repl.
* Optimize merge a little.Kaz Kylheku2017-01-291-4/+6
| | | | | * lib.c (merge): Eliminate extra call to cdr by keeping the result of cdr_l, and working with the location.
* bugfix: make list sorting stable, as documented.Kaz Kylheku2017-01-291-11/+11
| | | | | | | | | | | | * lib.c (merge): Fix unstable logic here. What we want is that when the item from list1 is *not less* than the item from list2, we take them in that order. Since all we have is a less function, we must test (less item2 item1). If this is false, then preserve the order, because when the keys are identical, the less function yields false. (sort_list): A similar change takes place here when we sort a list of length two (which is essentially an inlined case of merge).
* awk: support list of string as input source.Kaz Kylheku2017-01-292-4/+17
| | | | | | | | * 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.
* bugfix: read print consistency of shadowed symbols.Kaz Kylheku2017-01-291-7/+14
| | | | | | | | | | | | | | Suppose that a program-defined package is current, has usr as its :fallback, and has a :local symbol list. Then if 'usr:list is printed, it must print with the usr: package symbol because it is not visible. It is printing without the prefix. * lib.c (symbol_present): Function renamed to symbol_visible, which is much more descriptive of what its return value means. The bug in this function is that it does not stop searching when, in its search path, it encounters a symbol which has the same name as sym, but which isn't sym. But such a symbol makes sym invisible. This is now fixed.
* Simplify gethash variants using new function.Kaz Kylheku2017-01-292-12/+10
| | | | | | | | | * hash.c (gethash_e): New function. Just returns the entry cell if found, or else nil. This should have been written first. (gethash, gethash_f, gethash_n): Replace body with trivial one-liner based on gethash_e. * hash.h (gethash_e): Declared.
* doc: new package example showing function override.Kaz Kylheku2017-01-291-0/+39
| | | | | | | * txr.1: Example showing + symbol being replaced in a custom package with a local symbol, and a function being bound which overloads + to allow strings and numbers.
* 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.
* Expose expand_params as sys:expand-params.Kaz Kylheku2017-01-291-0/+1
| | | | | * eval.c (eval_init): Register sys:expand-params intrinsic bound to expand_params.
* bugfix: :filter not handled right in output var.Kaz Kylheku2017-01-263-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This issue was fixed in quasiliterals only. Because of the implementation duplicity between output vars and quasiliteral vars, we have to fix it in two places. When the parser handles quasiliterals, it builds vars without expanding the contents. The quasiliteral expander takes care of recognzing (sys:var ...) forms and properly handles them and their attributes, avoiding expanding the argument of a :filter keyword. When the parser handles an o_var that is a braced variable, it calls expand on its contents right there, then builds the (sys:var ...) form from the expanded contents. Why don't we just call expand_quasi in the o_var rule to have a single (sys:var ...) form expanded exactly how it is done in quasiliterals. * eval.c (expand_quasi): Change static function to external. * eval.c (expand_quasi): Declared. * parser.y (o_var): Construct an unexpanded (sys:var ...) form, and then wrap it in a one-element list. This is a de-facto quasi-items list, which can be expanded by expand_quasi. Then we pull the car of the expansion to get our expanded var.
* Expose defer-warning and dump-deferred-warnings.Kaz Kylheku2017-01-262-0/+55
| | | | | | | * unwind.c (uw_late_init): Register defer-warning and dump-deferred-warnings intrinsics. * txr.1: Documented.
* bugfix: forgotten autoload registrations.Kaz Kylheku2017-01-261-1/+2
| | | | * lisplib.c (except_set_entries): Add catch* and handle*.
* Version 166.txr-166Kaz Kylheku2017-01-266-672/+740
| | | | | | | | | | * 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-262-0/+29
| | | | | | | | | | * 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-262-5/+16
| | | | | | | | * 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*.
* Registering tentative def must purge warning.Kaz Kylheku2017-01-252-1/+1
| | | | | | | | * match.c (match_reg_var): No need to call uw_purge_deferred_warning here any more. * unwind.c (uw_register_tentative_def): Purge any deferred warnings for the tag.
* doc: update compat notes: new 165 value.Kaz Kylheku2017-01-251-0/+16
| | | | | * txr.1: Describe the Lisp expansion neglect in the pattern language that is fixed for 166, reversible with -C.
* Local macrolets in build become functions.Kaz Kylheku2017-01-252-6/+11
| | | | | | | | | | * 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-252-5/+27
| | | | | | | | | | | * 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-254-17/+41
| | | | | | | | | | | | | | | | | | * 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: wrong context form in mac-param-bind.Kaz Kylheku2017-01-251-1/+1
| | | | | | | * eval.c (do_expand): Expander for mac-param-bind is redundantly expanding the main expression and taking that as the epanded context form, rather than expanding the context form.
* Remove unused args_init function.Kaz Kylheku2017-01-251-5/+0
| | | | * args.h (args_init): Inline function removed.
* bugfix: take-while, take-until termination condition.Kaz Kylheku2017-01-241-2/+2
| | | | | | | * lib.c (take_while_list_fun, take_until_list_fun): We must terminate the output list when the output list is empty, and not try to apply the predicate to car(list) in that case.
* Expose plist to alist functions.Kaz Kylheku2017-01-242-1/+69
| | | | | | | | * eval.c (eval_init): Register plist-to-alist and improper-plist-to-alist intrinsics. * txr.1: Documented improper plist concept and new functions.
* Rename proper_plist_to_alist function.Kaz Kylheku2017-01-242-2/+2
| | | | | | | * lib.c (proper_plist_to_alist): Renamed to plist_to_alist. * lib.h (proper_plist_to_alist): Declaration replaced. (plist_to_alist): Declared.
* 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).
* New memp function for searching a plist.Kaz Kylheku2017-01-244-5/+54
| | | | | | | | | | * eval.c (eval_init): Register memp intrinsic. * lib.c (memp): New function. * lib.h (memp): Declared. * txr.1: Documented.