summaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
* 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.
* save-exe: new function.Kaz Kylheku2019-02-174-80/+86
| | | | | | | | | | | | | | * lisplib.c (save_exe_instantiate, save_exe_set_entries): New static functions. (lisplib_init): Register auto-load of save-exe module, keyed to save-exe symbol. * share/txr/stdlib/save-exe.tl: New file. * txr.1: Removing txr-embedded-arg.txr documentation and documenting save-exe in its place. * txr-embedded-arg.txr: File removed.
* scan-until-match, count-until-match: new functions.Kaz Kylheku2019-02-163-9/+83
| | | | | | | | | | | | | * regex.c (scan_until_common): New static function, made from read_until_match. (read_until_match): Now just wrapper for scan_until_common. (scan_until_match, count_until_match): New functions. (regex_init): Registered new intrinsics scan-until-match and count-until-match. * regex.h (read_until_match, scan_until_match): Declared. * txr.1: Documented.
* fill-buf-adjust: new function.Kaz Kylheku2019-02-163-1/+34
| | | | | | | | | * stream.c (fill_buf_adjust): New function. (stream_init): Register fill-buf-adjust intrinsic. * stream.h (fill_buf_adjust): Declared. * txr.1: Documented.
* buf-alloc-size: new function.Kaz Kylheku2019-02-163-0/+18
| | | | | | | | | * buf.c (buf_alloc_size): New function. (buf_init): buf-alloc-size intrinsic registered. * buf.h (buf_alloc_size): Declared. * txr.1: Documented.
* buf: fix wrong function name string.Kaz Kylheku2019-02-161-1/+1
| | | | * buf.c (length_buf): Replace incorrect name.
* sysrooting: trailing slash needed on directory.Kaz Kylheku2019-02-161-0/+4
| | | | | | | | | * txr.c (sysroot_init): prog_dir is missing a trailing slash, and this breaks the fallback case when we're running a renamed txr executable in the build directory. The presence of the trailing slash had also been documented for the txr-path variable, which is now obsolescent and undocumented. That is hereby fixed.
* txr-exe-path: New variable.Kaz Kylheku2019-02-152-4/+4
| | | | | | | | | * txr.c (sysroot_init): Make prog_path available via the txr-exe-path variable. The txr-path variable becomes obsolescent. * txr.1: Documented txr-exe-path; removed documentation for txr-path.
* linenoise: preserve too-large-to-read file.Kaz Kylheku2019-02-151-2/+11
| | | | | | * linenoise.c (edit_in_editor): If we can't read the file, then preserve the file, and replace the command line buffer with an error message in which the name of that file appears.
* listener: fix buffer overflow reading external file.Kaz Kylheku2019-02-151-6/+1
| | | | | | | | | When an external file is edited, and is longer than the listener's buffer allows, the buffer overflows, trashing the other fields in the linenoise structure, and memory beyond. * parser.c (lino_gets): Decrement nchar in the loop. Also, eliminate useless return case.
* linenoise: bugfix: vertical skip problem.Kaz Kylheku2019-02-141-1/+3
| | | | | | | | | | | | | | | | | | | | | This relates to the optimized insert at the end of the line. The following bug manifests itself. When the cursor is not at the bottom of the screen (e.g. fresh terminal after a clear screen), if blank lines are added to the buffer and then backspace is hit, the cursor strangely jumps down by multiple lines prior to the refresh. In a Windows CMD.EXE window, this shows up even at the bottom of the screen, because the CMD.EXE console responds to a downward movement (ESC[<n>B) beyond the bottom row by scrolling the screen, rather than clipping the movement. * linenoise/linenoise.c (refresh_multiline): When doing the elided refresh (l->need_refresh == 2), we must update not only l->maxrows but also l->oldrow. Otherwise when we do the real update, it will think that the cursor is on the first line, and try to move down to the last line.
* structs: derive type id from pointer.Kaz Kylheku2019-02-151-54/+8
| | | | | | | | | | | | | | | * struct.c (uptopow2_0, uptopow2_1, uptopow2_2, uptopow2_3, uptopow2_4, uptopow2_5, uptopow2): New macros. (struct struct_id_recycle): Declaration removed. (struct_id_counter, struct_id_stack): Static variables removed. (get_struct_id, recycle_struct_id): Static functions removed. (struct_type_finalize): No need to recycle struct ID; don't call removed recycle_struct_id function. (make_struct_type): Don't call removed get_struct_id to allocate ID. Rather, cast the struct_type handle pointer to unsigned integer, and divide by the next smallest power of two.
* structs: fix poorly maintained bitfield size.Kaz Kylheku2019-02-151-1/+1
| | | | | | | | * struct.c (struct struct_inst): When the dirty flag was added, the id field was not decreased by one bit to make space, so the desired packing is not being achieved any more. Let's just use TAG_SHIFT to reserve the maximum bits that will still let us fit a fixnum into id.
* structs: recycle IDs of dead struct types.Kaz Kylheku2019-02-151-7/+71
| | | | | | | | | | | | | * struct.c (nelem): New macro. (struct struct_id_recycle): New struct type. (struct_id_counter): Initialize to 1 instead of zero. (get_struct_id, recycle_struct_id): New static functions. (struct_type_finalize): From each slot symbol, remove the struct type's ID from it slot cache, and finally recycle the struct type ID. (make_struct_type): Use get_struct_id to obtain an ID for the new struct type, rather than directly incrementing the global counter.
* Version 210.txr-210Kaz Kylheku2019-02-146-619/+642
| | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise. * txr.vim, tl.vim: Regenerated.
* linenoise: fix multi-line mode regression.Kaz Kylheku2019-02-141-5/+16
| | | | | | | | | When Enter is input in multi-line mode, a ^M appears instead of advancing to the next line. When the display is refreshed, the ^M's are properly treated as line breaks. * linenoise.c (edit_insert): Let's restructure the conditional ladder here into a switch and handle ENTER by issuing CR-LF.
* Optimize hash operation with unsafe car/cdr.Kaz Kylheku2019-02-147-115/+132
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The associative lists that make up the chains of a hash table are guaranteed to be made of conses. We can use unsafe versions of car, cdr, rplaca and rplacd to speed up hash operations. * eval.c (op_dohash): Use unsafe operations on hash cell. * filter.c (trie_compress, regex_from_trie): Likewise. * hash.c (hash_equal_op, hash_print_op, hash_mark, hash_grow, hash_assoc, hash_assql, copy_hash_chain, gethash, inhash, gethash_n, sethash, remhash, hash_next, maphash, do_weak_tables, group_by, group_reduce, hash_keys_lazy, hash_keys, hash_values_lazy, hash_values, hash_pairs_lazy, hash_pairs, hash_alist_lazy, hash_uni, hash_diff, hash_symdiff, hash_isec, hash_subset, hash_update, hash_update_1, hash_revget): Likewise. * lib.c (us_rplaca, us_rplacd): New functions. (package_local_symbols, package_foreign_symbols, where, populate_obj_hash, obj_hash_merge): Use unsafe operations on hash cell * lib.h (us_rplaca, us_rplacd): Declared. * parser.c (circ_backpatch, get_visible_syms): Use unsafe operations on hash cell. * struct.c (method_name, get_slot_syms): Likewise.
* gethash_c: review uses and improve or replace.Kaz Kylheku2019-02-145-35/+32
| | | | | | | | | | | | | | | | | | | | * eval.c (env_fbind, env_vbind, reg_symacro): Use gethash_l instead of gethash_c to eliminate repeated cdr operations on the same cell. * hash.c (sethash): Since new_p is never used, eliminated it and use nulloc. (group_reduce): Use gethash_l instead of gethash_c. * lib.c (obj_init): Replace rplacd(gethash_c(...)) pattern whose return value is not used with with sethash. We lose some diagnosability here since sethash doesn't take a "self" argument. (obj_print_impl, obj_hash_merge): Use gethash_l instead of gethash_c. * parser.y (ensure_parser, parser_circ_def, get_visible_syms, rlset): Use gethash_l instead of gethash_c.
* gethash_f: removing function.Kaz Kylheku2019-02-143-45/+33
| | | | | | | | | | | | | | | | Uses of gethash_f can be replaced with gethash_e, which returns the hash cell directly rather than through a loc argument. Code that needs the value can call cdr itself. * hash.c (inhash, hash_isec, hash_update_1): Replace gethash_f with gethash_e. (gethash_f): Function removed. * hash.h (gethash_f): Declaration removed. * lib.c (use_sym, unuse_sym, find_symbol, unintern, intern_fallback, in, sel, populate_obj_hash): Replace gethash_f with gethash_e.
* symdiff: new function.Kaz Kylheku2019-02-144-9/+70
| | | | | | | | | | | | * eval.c (eval_init): Register symdiff intrinsic. * lib.c (symdiff): New function. * lib.h (us_car_p, us_cdr_p): New inline functions. (symdiff): Declared. * txr.1: Documented, also fixing issues not related to symdiff doc.
* optimizing diff, isec and uni for non-lists.Kaz Kylheku2019-02-134-41/+109
| | | | | | | | | | | | | | | Also, these functions now support hashes. * eval.c (eval_init): Register only the deprecated set-diff to the set_diff function. The diff intrinsic is now going to the new function named diff. * lib.c (diff): New function. (isec, uni): Rewritten to use seq_iter_t. * lib.h (diff): Declared. * txr.1: Documentation updated.
* num: reduce duplicate code.Kaz Kylheku2019-02-131-3/+1
| | | | | * lib.c (num): Use num_fast instead of an expression that is identical to the body of that inline function.
* Framework for iterating over sequences.Kaz Kylheku2019-02-132-0/+94
| | | | | | | | | | | | | | | | This has been needed for a while. While we have seq_info for classifying sequences to nicely dispatch code into various cases, those cases duplicate code. The code base could benefit from generic traversal. * lib.c (seq_iter_get_nil, seq_iter_get_list, seq_iter_get_vec, set_iter_get_hash): New static functions. (seq_iter_rewind, seq_iter_init): New functions. * lib.h (struct seq_iter, seq_iter_t): New struct type and its typedef name. (seq_iter_init, seq_iter_rewind): Declared. (seq_get): New inline function.
* hash-from-alist: new function.Kaz Kylheku2019-02-133-1/+33
| | | | | | | | | * hash.c (hash_from_alist_v): New function. (hash_init): Register hash-from-alist intrinsic. * hash.h (hash_from_alist_v): Declared. * txr.1: Documented.
* hash-symdiff: new function.Kaz Kylheku2019-02-133-1/+57
| | | | | | | | | * hash.c (hash_symdiff): New function. (hash_init): hash-symdiff intrinsic registered. * hash.h (hash_symdiff): Declared. * txr.1: Documented.