summaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
...
* New function: hash-invert.Kaz Kylheku2019-10-283-0/+127
| | | | | | | | | * hash.c (hash_invert): New function. (hash_init): hash-invert intrinsic registered. * hash.c (hash_invert): Declared. * txr.1: Documented.
* New function: identity*Kaz Kylheku2019-10-284-5/+25
| | | | | | | | | | | | | | | An version of identity with lax argument conventions. * eval.c (eval_init): Register identity* intrinsic. * lib.c (identity_star_f): New symbol variable. (identity_star): New function. (obj_init): gc-protect identity_star_f variable, and initialize it. * lib.h (identity_star_f): Declared. * txr.1: Documented.
* doc: bogus paragraph removed under vec-push.Kaz Kylheku2019-10-281-7/+0
| | | | | * txr.1: There is no relationship between vec-push and ref; nonsense paragraph removed.
* Version 227.txr-227Kaz Kylheku2019-10-264-5/+15
| | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise.
* configure: stray exitKaz Kylheku2019-10-261-3/+0
| | | | | * configure: remove stray exit statement added while debugging memalign test on Solaris.
* Version 226.txr-226Kaz Kylheku2019-10-257-953/+1035
| | | | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise. * txr.vim, tl.vim: Regenerated. * protsym.c: Likewise.
* configure: memalign fixes.Kaz Kylheku2019-10-252-2/+24
| | | | | | | | | | | | | | | | | | | | | This fixes build problems on Mac OS and Solaris due to the introduction of the use of memalign. * configure: After detecting that __EXTENSIONS__ is required on Solaris and adding that to lang_flags, we must call gen_config_make so that it becomes available to subsequent configure tests. On Solaris, memalign is just in <stdlib.h>, so let's test for that first, then test for a memalign in <malloc.h>, and in that case add HAVE_MALLOC_H into config.h. Also, fixing two bugs here. Firstly, the memalign test used inverted logic, causing HAVE_MEMALIGN to be defined on platforms that don't have it. Secondly, the dummy while loop that is just supposed to be a control structure for forward breaks turned infinite due to a missing break at the bottom. * lib.c: if HAVE_MALLOC_H is defined and nonzero, then include <malloc.h>.
* fixparam: signed/unsigned warning from GNU C++.Kaz Kylheku2019-10-252-2/+2
| | | | | | | * lib.h (FIXPARAM_MAX): Switch constant to signed type. * lib.c (func_vm): Use num instead of unum on FIXPARAM_MAX, since we are making it signed.
* hashing: partially revert 63feff9c.Kaz Kylheku2019-10-251-4/+4
| | | | | | | | | Mixing the hash seed with the hashes for characters, fixnums and pointers by multiplication doesn't make sense. It doesn't perturb the hash sufficiently. * hash.c (equal_hash): Do not multiply the hash by the seed for CHR, NUM, SYM, PKG and ENV.
* genvmop: bugfix: unbound variable.Kaz Kylheku2019-10-251-1/+1
| | | | | | | * genvmop.txr: The supposedly unused %oc-list% symbol macro that was removed from the assembler internals is in fact referenced here, causing a failure. We macro-replace this remaining instance of it by hand.
* parser: use faster, unsafe nreverse.Kaz Kylheku2019-10-253-5/+20
| | | | | | | | | | * lib.c (us_nreverse): New function. * lib.h (us_nreverse): Declared. * parser.y (clauses_opt, n_exprs, r_exprs): Use us_nreverse instead of nreverse to rorder lists built in reverse into final shape.
* circle notation: use faster access in backpatch.Kaz Kylheku2019-10-251-7/+5
| | | | | | * parser.c (circ_backpatch): Since we know that we have a CONS or VEC object, use direct access instead of going through type-safe accessors.
* circle notation: recycle conses in backpatching.Kaz Kylheku2019-10-241-2/+8
| | | | | | * parser.c (circ_backpatch): Recycle the conses belonging to the temporary linked list allocated during hash table and tree backpatching.
* stdlib: remove unneeded macros from compiled image.Kaz Kylheku2019-10-243-40/+44
| | | | | | | | | | | | | | | | | | A few macros in the library are local; they are needed only inside functions in the same module. This means they are not referenced by anything once those functions are compiled; we should not be carrying the compiled versions of these macros into the image. We wrap these macro definitions with eval-only, telling the compiler not to emit their compiled version into the output file. * share/txr/stdlib/asm.tl (with-lev-idx, defopcode, defopcode-derived): Wrap macro with eval-only. * share/txr/stdlib/compiler.tl (compile-in-toplevel): Likewise. * share/txr/stdlib/path-test.tl (sys:path-test): Likewise.
* New macro: ldo.Kaz Kylheku2019-10-233-1/+42
| | | | | | | | | | This is a left-argument-inserting syntactic sugar for do. * lisplib.c (op_set_entries): Add auto-load entry for ldo. * share/txr/stdlib/op.tl (ldo): New macro. * txr.1: Documented.
* op/do: clean up documentation-implementation problem.Kaz Kylheku2019-10-232-65/+143
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | It was reported by astute user vapnik spaknik that the documentation says thing about the do operator which are not actually true in the implementation. I've decided that one of them should be true, and so both implementation and documentation are changing. The documentation claims that (do set x) will produce a function that can be called with one argument; that argument will be assigned to x. That doesn't work, but this commit will make it work. The documentation has this example transformation: (do + foo) -> (lambda rest (+ foo . rest)) that cannot be made to work because do works with macros and special operators to which arguments can't be dynamically applied. This patch will not make the above work; instead the example is corrected. How do is going to work inow is that (do sym ...) syntax in which no implicit variables appear will be equialent to (do sym ... @1). The generated variadic function has one required argument which is implicitly added to the syntax. Obviously, that only works if that positon of the syntax is an evaluated form or place. Values of the -C option equal to 225 or less will restore the old do behavior. * share/txr/stdlib/op.tl (sys:op-expand): Support the new style of do, subject to backward compatibility. A hack is required here. We cannot discover the @1, @2 .. variables in the syntax until we fully expand it. But that code walk requires the syntax to be valid. For instance if (do set x) is specified, with the expectation that it is equivalent to (do set x @1), we cannot process that by code walking (set x). (set x) is invalid syntax. What we do is to *try* expanding it as (set x). If that doesn't work, we add a dummy gensym to the form to produce (set x #:gNNNN) and try expanding that. In that case, rather than adding @1 to the form, we replace the dummy gensym with @1. The algorithm is careful not to accidentally conceal real syntax errors in the form. If the form without the dummy gensym fails to expand, and the one with the dummy gensym expands fine but contains references to implicit parameters (@1, @2, ... @rest), we expand it again without the gensym and allow the error to propagate. Other aspects of this change are fairly trivial. Because the do logic possibly introduces a @1 that doesn't exist, near the end of this function we have to bind another metas variable which has an up-to-date copy of the gens slot. (op-ignerr): New macro; we can't use ignerr because that will create a bootstrapping cycle; ignerr expands to catch, and the catch macro uses do. Wrapping this in eval-only, since we don't need an op-ignerr macro in the compiled image. * txr.1: Documentation revised and updated. Differences between do and op put clarified and put into point form. Bad do examples corrected. Syntax of do now shown as having a required parameter that is an operator. Compat notes added.
* mpi: memory leak in mp_bit.Kaz Kylheku2019-10-221-1/+6
| | | | | | * mpi.c (mp_bit): If the argument is negative, and we have produced a temporary mp_int, we must clear it before returning.
* circle notation: some backpatching optimizations.Kaz Kylheku2019-10-211-6/+13
| | | | | | | * parser.c (circ_backpatch): For hashes and trees, if the count has not changed while traversing the elements, then it means nothing was backpatched: there is no need to do the extra expensive step of rebuilding the hash or tree.
* hash: observe count in eql-based hash.Kaz Kylheku2019-10-211-0/+3
| | | | * hash.c (eql_hash): Decrement count and bail if zero.
* hash: rename hash_rec_limit.Kaz Kylheku2019-10-181-10/+10
| | | | | | | | | | | | | | hash_rec_limit isn't a limit on recursion depth but on the elements traversed. * hash.c (hash_rec_limit): Variable renamed to hash_traversal_limit. (gethash_c, gethash_e, remhash, hash_equal): Use new name. (set_hash_rec_limit): Function renamed to set_hash_traversal_limit. (hash_init): set-hash-rec-limit intrinsic renamed to set-hash-traversal-limit. This function is undocumented, so no backward compatibility is provided.
* hash: get rid of hash_str_limit.Kaz Kylheku2019-10-181-18/+13
| | | | | | | | | | | | | | hash.c (hash_str_limit): Variable removed. (hash_c_str): Take count parameter. Observe the limit and update it. The count is scaled by 4 for strings: four characters for one count. (hash_buf): Likewise. (equal_hash): Pass count to hash_c_str and hash_buf. Use the count to determine how far to force a lazy string for hashing. (set_hash_str_limit): Static function removed. (hash_init): Removed sys:set-hash-str-limit intrinsic. This was used in genman.txr once, but that use was removed a year and a half ago.
* hash: observe count limit for vectors and hash tables.Kaz Kylheku2019-10-181-1/+3
| | | | | | * hash.c (equal_hash): Break out of hashing a vector when the count is exceeded. (hash_hash_op): Likewise for traversing a hash table.
* functions: provide accessors for basic properties.Kaz Kylheku2019-10-184-0/+124
| | | | | | | | | | | | | | * eval.c (eval_init): Register intrinsic functions fun-fixparam-count, fun-optparam-count, fun-variadic. * lib.c (get_param_counts): New static function. (fun_fixparam_count, fun_optparam_count, fun_variadic): New functions. * lib.h (fun_fixparam_count, fun_optparam_count, fun_variadic): Declared. * txr.1: Documented.
* doc: bitfield allocation rules: endiannness.Kaz Kylheku2019-10-171-4/+27
| | | | | * txr.1: Add discussion about endinanness to Bitfield Allocation Rules for completeness.
* compiler: warn on too many lambda args.Kaz Kylheku2019-10-172-0/+4
| | | | | | | | | * share/txr/stdlib/vm-param.tl (%max-lambda-fixed-args%): New symbol macro. * share/txr/stdlib/compiler.tl (compiler comp-lambda): If the nubmer of fixed parameters exceeds %max-lambda-fixed-args%, then issue a warning.
* vm: prevent overflow of fixparam field in function.Kaz Kylheku2019-10-172-11/+22
| | | | | | | | | | | | | Functions can only have 127 fixed parameters; some code ignores this when assigning to the bitfield. * lib.h (FIXPARAM_BITS, FIXPARAM_MAX): New preprocessor symbols. (struct func): Use FIXPARAM_BITS for defining fixparam and optargs bitfields instead of hard-coded 7. * lib.c (func_vm): Sanity check the fixparam and reqags parameters: 0 <= reqargs <= fixparam <= FIXPARAM_MAX.
* doc: grammar fix in datagram streams.Kaz Kylheku2019-10-171-1/+1
| | | | | * txr.1: Subject-verb number agreement; also removing superfluous adverb.
* buffers: new functions buf-str and str-buf.Kaz Kylheku2019-10-172-0/+68
| | | | | | | * buf.c (make_owned_buf, buf_str, str_buf): New functions. (buf_init): buf-str and str-buf intrinsics registered. * txr.1: Documented.
* doc: read-until-match effect on stream position.Kaz Kylheku2019-10-161-0/+23
| | | | | | | * txr.1: Document athat the read-until-match, scan-until-match and count-until-match functions leave the stream position in an unspecified state, since the position returned by seek-stream doesn't take into account push-back characters.
* doc: relocate misplaced buffer functions.Kaz Kylheku2019-10-161-63/+63
| | | | | | * txr.1: The descriptions of file-get-buff, command-get-buf, file-put-buf, file-append-buf and command-put-buf are relocated from FFI area to Buffers where they belong.
* doc: func-get-name formatting.Kaz Kylheku2019-10-161-2/+2
| | | | * txr.1: Fix two instances of bungled method name meta-syntax.
* doc: #H() can't be written #H nil.Kaz Kylheku2019-10-161-1/+8
| | | | * txr.1: Document that #H() requires the parentheses.
* New function: copy-tree.Kaz Kylheku2019-10-164-0/+80
| | | | | | | | | | * eval.c (eval_init): Register copy-tree intrinsic. * lib.c (copy_tree): New function. * lib.h (copy_tree): Declared. * txr.1: Documented.
* copy-alist: no mapcar.Kaz Kylheku2019-10-161-1/+4
| | | | | * lib.c (copy_alist): Rewrite using list_collect iteration. endp is used for detecting improper list.
* copy-cons: more efficient; copies lconses.Kaz Kylheku2019-10-162-8/+34
| | | | | | | | | * lib.c (copy_cons): Rewrite to copy the object in a more low-level way, rather than going through the accessors and constructors. Now copies LCONS as LCONS, including its update function. * txr.1: copy-cons re-documented.
* tree: printing: handle unnamed functions.Kaz Kylheku2019-10-161-3/+7
| | | | | | | * tree.c (tree): If the tree abstraction functions don't have a name, then use the functions themselves as the names, rather than nil. Otherwise the printed representation of the tree will look like it has the default abstraction functions.
* tree: copy-search-tree function.Kaz Kylheku2019-10-164-0/+49
| | | | | | | | | | | | | * lib.c (copy): Handle tree objects via copy_search_tree. * tree.c (deep_copy_tnode): New static function. (copy_search_tree): New function. (tree_init): copy-search-tree intrinsic registered. * tree.h (copy_search_tree): Declared. * txr.1: Documented copy-search-tree, and copy function's use thereof.
* tree: node set functions and syntactic places.Kaz Kylheku2019-10-165-1/+98
| | | | | | | | | | | | | | | | | * lisplib.c (defset_set_entries): Autoload entries for left, right and key. * share/txr/stdlib/defset.tl (left, right, key): New simple-form defsets. * tree.c (set_left, set_right, set_key): New functions. (tree_init): Register intrinsics set-left, set-right and set-key. * tree.h (set_left, set_right, set_key): Declared. * txr.1: key, left and right classified as accessors. Documented set-key, set-left and set-right.
* tree: introduce copy-tnode.Kaz Kylheku2019-10-164-0/+30
| | | | | | | | | | | | * lib.c (copy): Handle TNOD casee via copy_tnode. * tree.c (copy_tnode): New function. (tree_init): copy-tnode intrinsic registered. * tree.h (copy_tnode): Declared. * txr.1: copy function documented as handling tnode type via copy-tnode. That function is documented.
* tree: api: harmonize deletion with insertion.Kaz Kylheku2019-10-152-5/+39
| | | | | | | | | * tree.c (tree_delete): Renamed to tree_delete_node. (tree_delete): New function which returns element rather than node. (tree_root): Registered tree-delete-node intrinsic. * txr.1: Documented.
* doc: trees and tree nodes documented.Kaz Kylheku2019-10-151-0/+562
| | | | | | * txr.1: Documenting #T and #N literals, and the associated functions and special variable. The yype hierarchy graph is updated with the new types.
* doc: hash-iter missing in diagram.Kaz Kylheku2019-10-151-0/+2
| | | | | * txr.1: Add hash-iter into type hierarchy diagram under [cobj types].
* lib: middle_pivot: whitespace fix.Kaz Kylheku2019-10-151-4/+4
| | | | * lib.c (middle_pivot): Fix non-conforming indentation.
* eval: bugfix: don't pass eval env to macroexpand.Kaz Kylheku2019-10-131-1/+1
| | | | | | | * eval.c (eval_intrinsic): macroexpand must be called with the nil environment. If we had a macro env parameter, we could pass that. In any case, we mustn't pass an eval environment to the expander.
* hash: optimize vector access.Kaz Kylheku2019-10-121-22/+18
| | | | | | | | | | | | We use direct access instead of going through vecref/vecref_l. As a result of this change, I measured an 8% speedup in "make retest"! I'm also seeing a more than 10% speedup in "make" after "make clean-tlo" (i.e. recompiling the Lisp library). * hash.c (hash_mark, hash_grow, copy_hash, gethash_c, gethash_e, remhash, hash_next, hash_peek, do_weak_tables): Access the table directly.
* hash: use ucnum for hash values everywhere.Kaz Kylheku2019-10-122-12/+12
| | | | | | | | | | | | | | | | | | | One consequence of this is that we no longer pass negative values to vecref; that functon was protecting us from the consequences of this signed/unsigned mixup, at the cost of cyles. * hash.c (struct hash_ops): hash parameter in assoc_fun and acons_new_c_fun pointers changes from cnum to ucnum. (hash_assoc, hash_assql, hash_assq): hash parameter changes to ucnum. (hash_acons_new_c, hash_aconsql_new_c, hash_aconsq_new_c): Likewise. (gethash_c, gethash_e, remhash): Variable which captures the output of the hashing function is now ucnum instead of cnum. * lib.h (struct cons_hash_entry): Member hash changes from cnum to ucnum.
* doc: document :eq-based.Kaz Kylheku2019-10-111-12/+17
| | | | | | * txr.1: the :eq-based keyword and its semantics is documented, along with its mutual exclusion against the other two.
* hash: strengthen type mutual exclusion check.Kaz Kylheku2019-10-111-8/+13
| | | | | | | | | | * hash.c (equal_based_p): Take additional argument eq indicating that :eq-based has been specified. Check all three exclusive combinations. (hashv): Call equal_based_p unconditionally, even when :eq-based is specified and we don't use this function's return value so we benefit from that function's exclusion check. Pass the eq boolean, as required.
* parser: use eq-based hash for source location info.Kaz Kylheku2019-10-111-1/+1
| | | | | * parser.l (parser_l_init): Assign an eq-based hash to form_to_ln_hash.
* parser: use eq-based hash for circular notation.Kaz Kylheku2019-10-111-1/+1
| | | | | * parser.c (parser_circ_def): Instantiate p->circ_ref_hash as eq-based hash, not eql-based.