summaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
* expander: tree-bind: fix incorrect param env.Kaz Kylheku2019-03-081-2/+2
| | | | | | | | | | | | * eval.c (do_expand): A wrong thing is being done here: the macro is extended using the original parameter syntax, that has not been processed by expand_params. The body is then expanded using that environment. This subtly breaks support for parameter macros in tree-bind. They work, but there are spurious warnings about undefined variables during expansion, and the wrong scope handling can introduce bugs. The right thing is to derive new_menv by pulling the parameter symbols from params_ex.
* New macro: defset.Kaz Kylheku2019-03-064-2/+380
| | | | | | | | | | | | | | * lisplib.c (defset_instantiate, defset_set_entries): New static functions. (lisplib_init): Register auto-load of defset.tl, keyed on defset symbol. * share/txr/stdlib/defset.tl: New file. * share/txr/stdlib/paramt.tl (param-parser-base opt-syms): New method. * txr.1: Documented.
* doc: justify lack of seed keyword in hash construction.Kaz Kylheku2019-03-051-0/+8
| | | | | | * txr.1: The hash function doesn't support a keyword like :seed <n> to specify the hash seed. Adding an explanation of why. Spoiler: security reason.
* doc: fix too-wide make-hash syntaxKaz Kylheku2019-03-051-1/+2
| | | | | * txr.1: Fold make-hash over two lines to avoid 80 col overflow under man.
* lambda expressions aren't fboundp.Kaz Kylheku2019-03-031-5/+11
| | | | | | | | | | | | | | | | | | We don't want (fboundp '(lambda ...)) to be true, or (symbol-function '(lambda ...)) to yield a function. This also fixes funny print formatting of lambda expressions. * eval.c (lookup_fun): Do not recognize lambda expressions. Also, return nil for unknown syntax; don't bother looking it up in the hashes. (do_eval): We now have to check for a lambda expression in the car position to evaluate it; lookup_fun will no longer do that. (op_fun): The interpreted fun oprator must also check for lambda itself. (do_expand): A small code change is required here to avoid spuriously warning about a lambda in the car position.
* Fix use of comma operator as statement terminator.Kaz Kylheku2019-03-031-2/+2
| | | | | | * eval.c (fmakunbound, mmakunbound): Replace comma operator with statement terminator, an unintentional stylistic oddness. No behavior change.
* compiler: use new load-for.Kaz Kylheku2019-03-021-2/+1
| | | | | * share/txr/stdlib/compiler.tl: use load-for macro to load the param module.
* New macro: load-for.Kaz Kylheku2019-03-022-0/+184
| | | | | | | | | * eval.c (me_load_for): New function. (rt_load_for): New static function. (eval_init): Register load-for macro and sys:rt-load-for intrinsic function. * txr.1: Documented.
* eval: introduce variable for usr:var symbol.Kaz Kylheku2019-03-021-1/+2
| | | | | | * eval.c (usr_var_c): New symbol variable. The existing var_s hold sys:var, not usr:var. (eval_init): var symbol interned in usr package.
* ffi, eval: move struct_s.Kaz Kylheku2019-03-023-4/+4
| | | | | | | | | | * eval.c (struct_s): Now defined here. (eval_init): struct now interned here. * eval.h (struct_s): Declared. * ffi.c (struct_s): Definition removed. (ffi_init) struct no longer interned here.
* listener: return value regression.Kaz Kylheku2019-03-011-2/+2
| | | | | * parser.c (lino_getl, lino_gets): Return null pointer on EOF, restoring original behavior that was broken by recent patches.
* listener: fix buffer overflow loading overlong history line.Kaz Kylheku2019-03-011-6/+1
| | | | | * parser.c (lino_getl): Same fixes that were applied two weeks ago to lino_gets in commit b76c5760. Always check for copy and paste!
* compiler: fix (fun (lambda ...)).Kaz Kylheku2019-02-281-4/+8
| | | | | | | | * share/txr/stdlib/compiler.tl (compiler comp-fun): Recognize a lambda expression argument. The neglect to do this is causing a miscompilation of (fun (lambda ...)) to a single getf instruction that processes raw syntax at run time and yields an interpreted lambda.
* compiler: fix broken inline lambda.Kaz Kylheku2019-02-281-6/+9
| | | | | | | | | | | | | | * share/txr/stdlib/compiler.tl (lambda-apply-transform): Fix failure to bind the additional expresions to the rest variable, causing a too many arguments error to be reported. That is ((lambda (. x)) 1) would fail to compile. When binding the trailing fixed arguments to rest, we also pull in the apply list; this matches interpreted behavior, for instance ((lambda (a . b) (list a b)) 1 2 . 3) must return (1 (2 . 3)). In this case, the 3 comes into this function as (3) via the apply-list-expr argument; if we don't include that and bind only the remaining fix-args, then we get the output (1 (2)).
* compiler: fix (apply (fun (lambda ..))).Kaz Kylheku2019-02-281-1/+1
| | | | | | | * share/txr/stdlib/compiler.tl (compiler comp-fun-form): Fix an instance of sym not being unquoted into the quasiquote template, causing the compiler to compile a call to the nonexistent function called sym.
* compiler: move parameter parsing to separate file.Kaz Kylheku2019-02-282-38/+68
| | | | | | | | | | Some upcoming work is going to use these structures. * share/txr/stdlib/compiler.tl (param-parser-base fun-param-parser, mac-param-parser): These struct definitions move to param.tl. * share/txr/stdlib/param.tl: New file.
* asm: getlx, setlx: disassembler bug.Kaz Kylheku2019-02-271-2/+2
| | | | | * share/txr/stdlib/asm.tl (op-getlx dis, op-setlx dis): Decode the small operand destination field correctly as such.
* doc: mention lines limitation of listener.Kaz Kylheku2019-02-271-0/+4
| | | | | | * txr.1: Editing a buffer that has more lines than the terminal can display sort of works but is is sub-par; let's document this.
* linenoise: raise line length from 1023 to 4095.Kaz Kylheku2019-02-262-4/+3
| | | | | | * linenoise.c (LINENOISE_MAX_LINE): Change to 4096. * txr.1: Updated.
* doc: grammar in update expander description.Kaz Kylheku2019-02-261-1/+1
| | | | | * txr.1: Add missing word in a sentence under The Update Expander.
* doc: fix references to sys:expand.Kaz Kylheku2019-02-261-9/+9
| | | | | * txr.1: In a few places, we are referring to sys:expand which has been made public as usr:expand.
* linenoise: deal with some lingering line wrap glitch.Kaz Kylheku2019-02-261-0/+6
| | | | | | | | | | | | | | | | | | The optimized character insert case must handle the situation of the cursor going off the edge of the screen when a character is output in the last column in a manner that is consistent with the regular insert, leaving the linenoise structure in the same state that a full refresh would. * linenoise/linenoise.c (refresh_multiline): In the optimized character insert case indicated by need_refresh == 2, we must add the check for the cursor being in the dead spot past the edge of the screen, just like we do later in the function for the regular refresh case. In that case we must advance the cursor to the next line to get it out of the dead spot, and adjust maxrows if necessary. We know we are in the dead spot from the two rows values output by screen_rows. That function puts out a nrow value that exceeds rows when that is the case.
* linenoise: defensive null pointer check.Kaz Kylheku2019-02-261-1/+2
| | | | | | | | | | * linenoise/linenoise.c (move_cursor_multiline): If the npos argument happens to be equal to the current position (the operation is a null move), then no movement is generated. In that case, no ab_append operation is called, and ab.b will stay null; this null pointer then gets passed to lino_os.puts_fn as the string to output, and that will blow up. This situation hasn't actually been observed.
* build: remove nonexistent config option.Kaz Kylheku2019-02-261-2/+2
| | | | | | * Makefile (dbg/%-win.o, opt/%-win.o): Don't pass CONFIG_WIN_MAIN=1 preprocessor symbol; it's not referenced anywhere, and never has been.
* bugfix: :key param expander -- symbol.Kaz Kylheku2019-02-251-0/+5
| | | | | | | | | | The -- symbol is not interned in the usr package. This means that the keyparams.tl code is interning the symbol -- in the sys package, and look for that as a delimiter. Application code is interning its own -- symbol, such as pub:-- and passing that. * lisplib.c (keyparams_set_entries): Intern the -- symbol.
* doc: reorganize hashing documentation.Kaz Kylheku2019-02-251-85/+123
| | | | | | | | * txr.1: Moving description of hash table sfrom under make-hash function into an intro section under Hashing Library. Revising some of the text on weak keys and values, adding discussion of hash seed, and mentioning clearhash in the text that discusses deletion of keys from a hash being traversed.
* Version 212.txr-212Kaz Kylheku2019-02-246-917/+955
| | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise. * txr.vim, tl.vim: Regenerated.
* bracket: new function.Kaz Kylheku2019-02-244-0/+87
| | | | | | | | | | * eval.c (eval_init): Register bracket intrinsic. * lib.c (bracket): New function. * lib.h (bracket): Declared. * txr.1: Documented.
* ffi: gc bug in cptr type.Kaz Kylheku2019-02-241-0/+1
| | | | | * ffi.c (ffi_type_common_mark): We must mark tft->tag field whih is used by the cptr type and is otherwise nil.
* ffi: gc bug in enum type.Kaz Kylheku2019-02-241-5/+5
| | | | | | | | * ffi.c (make_ffi_type_enum): Allocate the sym_num an num_sym hashes before the type object. That ensures they are older, and may be assigned into the object without setcheck. Also, move those assignments earlier, before the loop which populates the hashes.
* hash: gc issue in clearhash.Kaz Kylheku2019-02-241-0/+1
| | | | | | * hash.c (clearhash): Assignment of new table into hash requires setcheck, because it's putting a new object into an old one.
* hash: remove redundant assignment from hash_grow.Kaz Kylheku2019-02-241-1/+1
| | | | | | * hash.c (hash_grow): The new_table value is stored in h->table twice. First directly and then via the set macro. Let's just use setcheck, which avoids the intermediate loc object.
* parser: gc bug in handling circular notation.Kaz Kylheku2019-02-241-1/+3
| | | | | | | * parser.c (parser_circ_def): When we lazily add the circ_ref_hash to the parser, this is possibly a wrong-way assignment (pointer to a baby object being stored into a mature object). The handling for this is missing.
* path-sep-chars: document first char being special.Kaz Kylheku2019-02-231-0/+4
| | | | | * txr.1: If a platform has multiple path separator characters and one of them is preferred, it appears first. Document this.
* printer: revise package prefix decision.Kaz Kylheku2019-02-231-24/+50
| | | | | | | | | | | | | | | | | | | | | | | * lib.c (symbol_needs_prefix): revisiting the wrongheaded requirements codified in 7bc150f, because the ergonomics is bad. In a package that has a local symbol that has the same name as one in a fallback list, that symbol is always printed with a prefix, which is annoying. The new rules are simple: if the symbol being printed is the one which is visible, then it gets no package prefix. Also, this function now handles the full responsibility for the prefix calculation, including for keyword symbols and uninterned symbools. It returns nil to indicate no prefix is needed, or else a character string. Moreover, logic is added to detect symbols which have a home package, but are uninterned from it, which should be printed with the "#" prefix. Lastly, this function is optimized to avoid unnecessary gethash operations. If a symbol S's home package is P, and P contains no hidden symbols (overwhelmingly common situation), then S is interned in P; no need to do the hash lookup to check this. (obj_print_impl): Symbol printing simplified: if symbol_needs_refix returns non-nil, that string value is the prefix.
* hashing: provide unsafe hash count.Kaz Kylheku2019-02-222-0/+7
| | | | | | | * hash.c (us_hash_count): New function. Blindly assumes that the argument is a hash. * hash.h (us_hash_count): Declared.
* linenoise: Ctrl-X Ctrl-P missing from cheatsheet.Kaz Kylheku2019-02-211-4/+4
| | | | | | | * linenoise/linenoise.c (show_help): Rearrange contents. ^X+Tab moves from page 3 to page 2, to a spot where there is just enough room. That gives us room to place ^X^P on page 3.
* listener: fix hang when stringifying output.Kaz Kylheku2019-02-211-1/+2
| | | | | | | | | | | | | | | | | | The issue is that when *listener-pprint-p* is set, then the evaluation is printed using pprinl. The user may have arranged for that to safely work when there are circular objects in the print. But then the listener ignores *listener-pprint-p* when saving the output object as a string (which is done for the sake of the Ctrl-X Ctrl-P paste-previous-output feature). The tostring function is used which can blow up on an object containing circular structure, even though the object was successfully printed. The user is puzzled: why was the result of the evaluation printed completely and perfectly, yet the image has hanged? * parser.c (repl): Do not use tostring for converting the evaluated output to a string. Choose between tostring and tostringp based on the *listener-pprint-p* variable.
* doc: clarification in cptr-int.Kaz Kylheku2019-02-201-2/+2
| | | | | * txr.1: Remove unclear pronoun in remark about addressing structure.
* doc: wrong word under cptr.Kaz Kylheku2019-02-201-1/+1
| | | | * txr.1: Fix "an" that should be "and".
* pprof: generate much smaller expansion.Kaz Kylheku2019-02-191-17/+21
| | | | | | | | | * eval.c (me_pprof): Instead of emitting open code which destructures the output of pprof and prints a diagnostic, let's do that inside a run-time support function called sys:rt-pprof, so (pprof x) now expands to (rt:pprof (prof x)). (rt_pprof): New function. (eval_init): Register sys:rt-pprof intrinsic.
* compiler: prof instruction tries to modify t0.Kaz Kylheku2019-02-191-2/+2
| | | | | | | | | | * share/txr/stdlib/compiler.tl (compiler comp-prof): We must use the incoming oreg as the destination for prof, and not try to use output register indicated by the compiled fragment. That fragment may indicate nil as its output, which we may not clobber. Since we are telling the sub-compile to try to put the fragment's output into our oreg, in most cases they still get merged so a single register is re-used.
* struct: optimizations in new operator.Kaz Kylheku2019-02-191-2/+4
| | | | | | | | | | * share/txr/stdlib/struct.tl (new): Use struct-from-args and struct-from-plist whenever possible; don't use make-struct unless the syntax specifies both BOA and plist arguments. Using struct-from-plist instead of make-struct means we can now entirely avoid consing a list in compiled code. Code like (new point x 0 y 0) now allocates nothing but the struct.
* structs: optimize struct creating functions.Kaz Kylheku2019-02-191-7/+19
| | | | | | | | | | | | | | | | We reduce consing in the structure instantiating API. * struct.c (make_struct_impl): New static function, formed from make_struct. This takes two "struct args *" arguments, for both the slot/pair property list and the BOA list. (make_struct): Now a wrapper for make_struct_impl. (struct_from_plist): Call make_struct_impl instead of make_struct, avoiding the args_get_list operation that potentially conses args on the stack into a list. Diagnosis is improved because make_struct_impl takes a self argument. (struct_from_args): Call make_struct_impl instead of make_struct.
* mpi/arith: optimize "highest bit" with GCC builtins.Kaz Kylheku2019-02-192-2/+14
| | | | | | * arith.c (highest_bit): On GCC, use __builtin_clz. * mpi/mpi.c (s_highest_bit): Likewise.
* Version 211.txr-211Kaz Kylheku2019-02-186-909/+949
| | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise. * txr.vim, tl.vim: Regenerated.
* structs: bugfix: slot_cache null check.Kaz Kylheku2019-02-181-6/+7
| | | | | | * struct.c (struct_type_finalize): We must check slot_cache for null. The slot symbols of a struct type being finalized might not have slot caches.
* RELNOTES: repair bad dates.Kaz Kylheku2019-02-181-1/+2
| | | | | * RELNOTES: Restore correct date under TXR 209. Add missing date under 210.
* gc: bug: finalized objects not reclaimed.Kaz Kylheku2019-02-181-1/+11
| | | | | | | | | | | | | | | | | The problem: in an incremental GC run, when an generation 0 object is determined to be unreachable and has a registered finalizer, it ends up hanging around until a full GC. This is because it is marked as if it were reachable (just in case the finalizer re-introduces it into the object graph) and left to be processed at the next GC. However, what's missing is that the object is not in the freshobj array any more, and so it is not reclaimed by the sweep function. Effectively, it's as if the object had been promoted to gen 1. * gc.c (call_finalizers_impl): After invoking a finalizer, if the object is still in gen 0, add it to the freshobj array as if it had just been allocated. If there is no room in the freshobj array, set the full_gc flag, as usual.
* doc: clarify that ftw takes a list or path.Kaz Kylheku2019-02-171-50/+46
| | | | | * txr.1: Make it clearer that ftw operates on a list; that fact was too buried in the documentation.