summaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
...
* code review: switch case breaks.Kaz Kylheku2018-03-082-0/+4
| | | | | | | | | | * arith.c (c_unum): Add fallthrough comment. (minus): Add missing break after case that handles char minus heap object.. This luckily isn't a bug because type(anum) isn't RNG, and so when it falls through, the next case also falls through. * lib.c (car): Add missing fallthrough comment.
* New function: bignum-len.Kaz Kylheku2018-03-063-0/+46
| | | | | | | | | * arith.c (bignum_len): Wew function. (arith_init): Register bignum-len intrinsic. * arith.h (bignum_len): Declared. * txr.1: Documented.
* trace: bugfix in method redefinition check.Kaz Kylheku2018-03-011-2/+5
| | | | | | | | | | | | | | | If the trace module has been loaded, we can't define methods. Repro: 1> (trace) nil 2> (defmeth time foo (me)) ** static-slot-home: #<struct-type time> has no static slot named foo * struct.c (static_slot_ensure): Do the trace_check after calling static_slot_ens_rec so that the slot exists. If the slot doesn't exist, an exception occurs when sys:trace-canonicalize-name calls static-slot-home.
* bugfix: missing actions in reset-struct.Kaz Kylheku2018-02-282-1/+46
| | | | | | | | | | | | * struct.c (reset_struct): Perform the post-init actions are performed, not only the init actions. Also, catch exceptions and call finalizers, just like in a new structure instantiation. * txr.1: Document the requirements for finalizers being called by reset-struct, and clarify the issue of possible duplicate finalization registration. Add compat notes.
* bugfix: buf-get-* not allowing last byte of buffer.Kaz Kylheku2018-02-281-1/+1
| | | | | | | * buf.c (buf_get_bytes): Fix off-by-one test for reading past end of buffer. This prevents, e.g. a buf-get-u32 from the last four bytes of a buffer (or from a four-byte-long buffer, period).
* doc: wrong pluralizations of "function".Kaz Kylheku2018-02-271-3/+3
| | | | | | * txr.1: Fix three unrelated occurrences of the same mistake: "functions is", in reference to a single function.
* Require semicolon after static_{forward,def} macros.Kaz Kylheku2018-02-263-5/+5
| | | | | | | | | | | * lib.h (static_forward, static_def): At least the C version of these now require a trailing semicolon. * struct.c (struct_type_ops): Add required semicolon after static_def. * syslog.c (syslog_strm_ops): Add required semicolon after static_forward and after static_def.
* Version 190.txr-190Kaz Kylheku2018-02-187-1064/+1094
| | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise. * txr.vim, tl.vim, protsym.c: Regenerated.
* New listener feature: greedy evaluation feature.Kaz Kylheku2018-02-174-2/+112
| | | | | | | | | | | | | | | | * eval.c (eval_intrinsic_noerr): New function. * eval.h (eval_intrinsic_noerr): Declared. * parser.c (listener_greedy_eval_s): New symbol variable. (repl): Implement greedy evaluation loop, enabled by the *listener-greedy-eval-p* special. (parse_init): Intern the *listener-greedy-eval-p* symbol, storing it in the listener_greedy_eval_s variable. Register the symbol as a special variable. * txr.1: Documented *listener-greedy-eval-p* variable and the greedy evaluation feature that it controls.
* Lisp load function supports .txr files.Kaz Kylheku2018-02-163-31/+108
| | | | | | | | | | | | * eval.c (load): Instead of throwing error when a .txr file is opened, process it according to sensible requirements. * match.c (v_load): Store bindings in the current environment frame before evaluating Lisp, and then update afterward. This allows .txr files loaded from Lisp to continue matching with the current bindings and extend those bindings. * txr.1: Update documentation of load.
* Eliminate always false expression.Kaz Kylheku2018-02-161-1/+1
| | | | | | * txr.c (txr_main): Since parser.errors being nonzero is handled earlier, it must be zero at the final return point and need not be tested.
* bugfix: broken expansion of sys:lisp1-setq places.Kaz Kylheku2018-02-151-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | This bug shows up as a spurious warning and incorrect expansion from a from like (do set [@1 x] y). In this situation, sys:lisp1-setq is involved in the assignment to the place denoted by @1, because of the way the do operator expands the (set [@1 x] y) expression. The @1 meta-variable is replaced by a gensym, but some intermediate expansion takes place in an environment which has no binding for the gensym, causing the place to be treated as if it were a global variable, using sys:lisp1-setq. The subsequent real expansion in the environment in which the gensym is now bound then calls upon the expansion of sys:lisp1-setq, which proceeds via the expand_lisp1_setq function. But now the variable has a lexical binding. This bug doesn't show up in ordinary expressions like (set [foo x] y) which is why it went undetected for a year. * eval.c (expand_lisp1_setq): Fix the missing symbol in the generated code for the case when the symbol has a lexical variable binding. We must emit (sys:setq <sym> <value>), not (sys:setq <new-value>).
* Copyright year bump 2018.Kaz Kylheku2018-02-15101-102/+102
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * LICENSE, LICENSE-CYG, METALICENSE, Makefile, args.c, args.h, arith.c, arith.h, buf.c, buf.h, cadr.c, cadr.h, combi.c, combi.h, configure, debug.c, debug.h, eval.c, eval.h, ffi.c, ffi.h, filter.c, filter.h, ftw.c, ftw.h, gc.c, gc.h, glob.c, glob.h, hash.c, hash.h, itypes.c, itypes.h, jmp.S, lib.c, lib.h, lisplib.c, lisplib.h, match.c, match.h, parser.c, parser.h, parser.l, parser.y, protsym.c, rand.c, rand.h, regex.c, regex.h, share/txr/stdlib/awk.tl, share/txr/stdlib/build.tl, share/txr/stdlib/cadr.tl, share/txr/stdlib/conv.tl, share/txr/stdlib/doloop.tl, share/txr/stdlib/error.tl, share/txr/stdlib/except.tl, share/txr/stdlib/ffi.tl, share/txr/stdlib/getopts.tl, share/txr/stdlib/getput.tl, share/txr/stdlib/hash.tl, share/txr/stdlib/ifa.tl, share/txr/stdlib/keyparams.tl, share/txr/stdlib/op.tl, share/txr/stdlib/package.tl, share/txr/stdlib/path-test.tl, share/txr/stdlib/place.tl, share/txr/stdlib/pmac.tl, share/txr/stdlib/socket.tl, share/txr/stdlib/stream-wrap.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, signal.c, signal.h, socket.c, socket.h, stream.c, stream.h, struct.c, struct.h, strudel.c, strudel.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, win/cleansvg.txr: Extended Copyright line to 2018.
* bugfix: op module inversely depends on sys:l1-val.Kaz Kylheku2018-02-142-24/+64
| | | | | | | | | | | | | | | | | | | The problem is that the lop macro in op.tl generates code that uses sys:l1-val. That requires the place.tl module. But there is no autoload trigger for sys:l1-val. Even if there were, it wouldn't work because op.tl is lower level w.r.t. place.tl; place.tl uses op.tl. Let's just rewrite sys:l1-val and sys:l1-setq in C, so they live in the run-time core. * eval.c (sys_l1_val_s, sys_l1_setq_s): New symbol variables. (me_l1_val, me_l1_setq): New static functions. (eval_init): Intern sys:l1-setq and sys:l1-val symbols, binding these to the macro expanding functions. * share/txr/stdlib/place.tl (sys:l1-setq, sys:l1-val): Macros removed.
* cleanup: harmonize lisp1-eval-related symbol variables.Kaz Kylheku2018-02-142-8/+8
| | | | | | | | | | | | | | * eval.c (sys_lisp1_value_s): Declaration moved to be collocated with lisp1_setq_s. (lisp1_setq_s): Variable renamed to sys_lisp1_setq_s to match sys_lisp1_value_s. (do_expand): Follow rename of lisp1_setq_s. (eval_init): Follow rename; collocate initialization of vars. * protsym.c (lisp1_setq_s): Manually renamed to sys_lisp1_setq_s instead of full regeneration, which we do at release time.
* doc: fix compat note 156, again.Kaz Kylheku2018-02-141-2/+4
| | | | | | * txr.1: Add missing text to compensate for text that was accidentally edited out, regarding the return value of the empty case of caseq/caseql/casequal.
* New listener variable: *listener-pprint-s*.Kaz Kylheku2018-02-122-1/+27
| | | | | | | | | | * parser.c (listener_pprint_s): New symbol variable. (repl): Check new variable after each evaluation and print accordingly. (parse_init): Initialize listener_print_s with interned symbol and register the variable. * txr.1: Document *listener-pprint-s*.
* bugfix: intern public symbols in autoload files.Kaz Kylheku2018-02-071-0/+29
| | | | | | | | | | | | | | | | | | | | | | | This commit addresses a bug of the following type: (defpackage p (:fallback usr)) (in-package p) (let ((lb (new list-builder))) lb.(add 1)) ;; problem: this add is p:add the add symbol is not on the auto-load list; it occurs as a slot of the list-builder class, but is not interned when TXR starts. Thus the (:fallback usr) doesn't pick it up. Expected behavior is that add is usr:add. * lisplib.c (intern_only): New static function. (sock_set_entries, build_set_entries, getopts_set_entries, stream_wrap_set_entries): Define additional lists of supplemenary symbols which are passed to intern_only just to be interned in the usr package without autoload registratiions. These symbols are all slots documented for public use in various structures defined by the respective modules managed by these autoload functions.
* Version 189.txr-189Kaz Kylheku2018-02-067-1006/+1041
| | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise. * txr.vim, tl.vim, protsym.c: Regenerated.
* bugfix: don't record source loc of symbols and numbers.Kaz Kylheku2018-02-051-4/+22
| | | | | | | | | | | | | | | | | | This prevents a bug which manifests itself as a totally bogus file name and line number being reported in a diagnostic. The cause is that source loc info is recorded for an interned symbol when it is first encountered in one place in the code. Then that symbol occurs again in another place (perhaps a different file) in such a way that its source loc info is inherited into a surrounding generated form which now has incorrect source loc info: the location of the first occurrence of the symbol not of this form. Then when some error is reported against the form, the bogus source loc info is shown. * parser.y (rlviable): New static function. (rlset): Only record source loc for forms which satisfy rlviable.
* doc: write Equality Substitution section.Kaz Kylheku2018-02-051-0/+63
| | | | | | * txr.1: Several places in the document refer to a section called Equality Substitution which supposedly exists under the Structures section. As of now, it actually does!
* doc: clarify text under constantpKaz Kylheku2018-02-051-3/+3
| | | | | * txr.1: Restructure long sentence for readability, fixing awkward comma in the process.
* doc: more detail in ref/refset re: structs.Kaz Kylheku2018-01-311-5/+32
| | | | | | * txr.1: Describe fallback of ref and refset onto list-like operations if lambda/lambda-set are not supported.
* doc: grammatic agreement under equal method.Kaz Kylheku2018-01-301-1/+1
| | | | * txr.1: "behavior ... becomes" second person agreement.
* doc: bad formatting of lambda-set syntaxKaz Kylheku2018-01-301-1/+1
| | | | * txr.1: Fix run-on parenthesis.
* doc: clarification in :maxgap example.Kaz Kylheku2018-01-261-1/+1
| | | | | * txr.1: a :maxgap of zero also means that the collected items must match immediately.
* doc: fix "five lines" typo in :maxgap description.Kaz Kylheku2018-01-261-1/+3
| | | | | | Reported by Martin Dvořák. * txr.1: Word "five" should be "n".
* doc: fix mistake in summary of @(repeat)Kaz Kylheku2018-01-261-2/+2
| | | | | | | Reported by Martin Dvořák. * txr.1: In pattern matching clauses, repeat and rep are shorthands for collect and coll.
* doc: formatting of in directives intro.Kaz Kylheku2018-01-261-1/+3
| | | | * txr.1: use mono font for @(output).
* doc: some clarifications about dwim brackets.Kaz Kylheku2018-01-251-6/+13
| | | | | | txr.1: The equivalences between [x i] and some functions like ref are dynamic; they depend not only on the type ofx, but also whether i is a range or integer.
* Fix broken autoload of socket functions.Kaz Kylheku2018-01-251-0/+3
| | | | | | | * lisplib.c (sock_set_entries): Add missing sock-bind, sock-connect, sock-listen, sock-accept, sock-shutdown, open-socket, open-socket-pair, sock-send-timeout and sock-recv-timeout.
* doc: update car, cdr, rplaca, rplacd.Kaz Kylheku2018-01-081-26/+114
| | | | | | | | | | | * txr.1: Update the documentation to reflect the current handling of objects, eliminating some contradictions in the process, like text which says that rplacd is erroneous on anything but conses and lazy conses, followed by text which states other kinds of objects are allowed. The semantics of car and cdr forms as places is described strictly in terms of rplaca and rplacd, so the mechanism is then described in one place.
* tail: reduce calls to cdr.Kaz Kylheku2018-01-071-2/+3
| | | | | | * lib.c (tail): Don't call cdr on the same cell twice in the loop body. tail is used in list_collect and friends, which are used all over the place.
* term: move near site of use.Kaz Kylheku2018-01-073-8/+7
| | | | | | | | | * eval.c (term): Function here from lib.c, and changed to static. It is used only by iapply. * lib.c (term): Function moved to eval.c. * lib.h (term): Declaration removed.
* listref_l: remove.Kaz Kylheku2018-01-062-18/+0
| | | | | | * lib.c (listref_l): Unused function removed. * lib.h (listref_l): Declaration removed.
* refset: implement objects that support car method.Kaz Kylheku2018-01-061-12/+46
| | | | | | | | | | | | | | refset and range assignment is implemented for objects that have no lambda-set but do have a car method. * lib.c (refset): Implementation for lists rewritten to avoid listref_l, and use nthcdr instead. For structs, if there is no lambda-set method, but a car method exists, jump to the list case: the idea is that we can cdr down and then use rplaca. (dwim_set): Error handling streamlined. In this function too, we check whether there is a car method and branch to the list case.
* nthcdr: terminate loop if end of list hit.Kaz Kylheku2018-01-051-1/+1
| | | | | * lib.c (nthcdr): Terminate loop when nil is hit rather than continuing to count down to zero.
* car, cdr: self-identify in error message.Kaz Kylheku2018-01-051-2/+2
| | | | | * lib.c (car, cdr): Type mismatch messages now identify functions.
* car, cdr: fall back on lambda method.Kaz Kylheku2018-01-031-4/+24
| | | | | | * lib.c (car, cdr): Don't fail if the struct object has no car or cdr method. Use it if it is available, otherwise try to fall back on the lambda method if that is available.
* ltail: unused function.Kaz Kylheku2018-01-022-8/+0
| | | | | | | | * lib.c (ltail): Function removed. This was introduced at the same time as lazy_appendv and used only by it. That function was rewritten a few months ago and doesn't use lail. * lib.h (ltail): Declaration removed.
* seq_info: bugfix: wrong object tested obj_struct_p.Kaz Kylheku2018-01-021-1/+1
| | | | | | * lib.c (seq_info): The obj_struct_p test must be applied to obj, not to cls, which is a symbol. Due to this bug, seq_info would always report struct-based sequences as SEQ_NOTSEQ.
* seq_info: whitespace.Kaz Kylheku2018-01-021-1/+1
| | | | | * lib.c (seq_info): Incorrect indentation of else statement fixed.
* last: rewrite using seq_info.Kaz Kylheku2018-01-021-10/+17
| | | | | * lib.c (last): Use seq_info classification rather than relying on listp.
* eliminate cdr_l use from implementation of last.Kaz Kylheku2018-01-022-12/+8
| | | | | | * lib.c (lastcons): Return value is just the last cons rather than a loc. The only caller of this function is last. (last): Adapt to the new lastcons.
* Use rplaca and rplacd instead of set over car_l/cdr_l.Kaz Kylheku2018-01-017-28/+28
| | | | | | | | | | | | | | | | | | | | | | | This reduces the proliferation of car_l and cdr_l. With this change, nreverse should work on chains of objects that implement rplacd. * combi.c (comb_gen_fun_common, rcomb_gen_fun_common): Use rplaca. * eval.c (mappendv, mapdov): Likewise * hash.c (hash_equal_op): Likewise. * lib.c (nreverse, acons_new, aconsql_new, sort_list): Use rplaca and rplacd. * match.c (dest_set, v_gather, v_collect, v_flatten, v_cat, v_output, v_filter): Likewise * parser.c (ensure_parser): Use sys_rplacd. * unwind.c (uw_register_subtype): Use rplacd.
* sub and replace redirect to structure methods.Kaz Kylheku2018-01-013-6/+121
| | | | | | | | | | | | | * lib.c (replace_obj): New static function. (sub): Handle struct case via lambda method. (replace): Handle struct case via replace_obj. * txr.1: Documented. * tests/012/aseq.tl (add): The lambda method now has to handle a range argument. One test case uses the last function, which for non-lists relies on sub, which now calls the lambda method if the object has one.
* New inlined test for struct object.Kaz Kylheku2017-12-313-19/+20
| | | | | | | | | | | * lib.c (seq_info, car, cdr, make_like, nullify, generic_funcall, copy, length, empty, ref, refset, dwim_set, dwim_del, populate_obj_hash): Use new obj_struct_p test when we know that the object is a COBJ. * struct.c (struct_inst_ops): Change from static to extern. * struct.h (ob_struct_p): New inline function.
* New methods rplaca and rplacd.Kaz Kylheku2017-12-304-2/+101
| | | | | | | | | | | | | | | * eval.c (eval_init): Register rplaca and rplacd using new rplaca_s and rplacd_s symbol variables. * lib.c (rplaca_s, rplacd_s): New symbol variables. (rplaca): Handle struct object via rplaca method, if it has one, otherwise lambda-set, if it has that, or else error out. (rplacd): Handle struct object via rplacd method. * lib.h (rplaca_s, rplacd_s): Declared. * txr.1: Documented rplaca and rplacd methods.
* refset: better diagnostics.Kaz Kylheku2017-12-291-1/+3
| | | | | | * lib.c (refset): If structure has no lambda-set method, diagnose it like that, rather than "not a sequence". Also, diagnostics should use refset:, not ref:.
* doc: invoke-catch: no such function as get-framesKaz Kylheku2017-12-291-2/+3
| | | | | * txr.1: Fix wording under invoke-catch which refers to a nonexistent function called get-frames.