| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
It has been reported by user cielesti that some of our
crypt tests fail on the Musl library.
Musl has some additional agorithms so it yields
a meaningful hash for a "$0$" salt, as well as for "$9$".
Musl uses "*" and "x" as error tokens rather than "*0"
and "*1". We need to change how we detect error tokens.
* sysif.c (crypt_wrap): Detect error tokens only by their
length: if a string emerges from crypt or crypt_r, whose
length is less than 13, it's an error token.
* tests/018/crypt.tl: Drop the tests that require :error
for salts "$0$" and "$9$", replacing them with a test
for a salt that is almost certainly invalid in all C libraries
on Linux.
* txr.1: Document that crypt throws an error exception and
under what circumstances (when the C library function does
what).
|
|
|
|
|
|
|
|
|
|
|
| |
* stream.c (sh_esc, sh_esc_all, sh_esc_dq, sh_esc_sq): New static
functions.
(stream_init): sh-esc, sh-esc-all, sh-esc-dq, sh-esc-sq: Intrinsics
registered.
* tests/018/sh-esc.tl: New file.
* txr.1: Documented.
|
|
|
|
|
|
|
|
|
|
| |
* lib.[ch] (str_esc): New function.
* eval.c (eval_init): str-esc intrinsic registered.
* tests/015/esc.tl: New file.
* txr.1: Documented.
|
|
|
|
|
|
|
|
|
| |
* stdlib/awk.tl (awk-state prn): Return nil in the no-argument
case instead of returning whatever put-string returns.
* tests/015/awk-misc.tl: New file.
* txr.1: Documented.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
These remove repetitive (op ...) syntax from
the arguments of functional combinators.
* stdlib/opt.tl (opf, lopf): New macros.
* autoload.c (op_set_entries): Register opf and
lopf as autoload triggers.
* tests/012/op.tl: New tests.
* txr.1: Documented.
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* autoload.c (csort_set_entries): Register csort-group
as autoload trigger for stdlib/csort.tl.
* stdlib/csort.tl (csort-group): New function.
* tests/012/sort.tl: Tests for sort-group and csort-group.
* txr.1: Documented.
* stdlib/doc-syms.tl: Updated.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* arith.c (tofloat_s, toint_s): New symbol variables.
(tofloat, toint): If the argument is a COBJ, handle
it via do_unary_method.
(arith_init): Initialize new symbol variables.
The functions tofloat, toint, tofloatz and tointz.
are now registered here, rather than eval_init.
* eval.c (eval_init): Remove registrations of tofloat,
toint, tofloatz and tointz.
* tests/016/ud-arith.tl: New tests.
* txr.1: Documented.
* stdlib/doc-syms.tl: Updated.
|
|
|
|
|
|
| |
* tests/016/ud-arith.tl (numbase): Add methods for
the newer functions: cbrt, erf, ...
Add tests covering these.
|
|
|
|
|
|
|
|
|
|
|
| |
* tree.c (tr_delete_specific): We cant' juse use key(node)
as the search key; we must apply the tree's key function
to the node key field to retrieve the correct search key.
* tests/010/tree.tl: New test case which fails without
this bugfix: a node which is the left subtree of the root
node doesn't get deleted since the search is led astray
by the wrong key object.
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* lib.c (unuse_sym): A used symbol may now appear in a package
under a different name. So if we don't find a symbol under
the symbol's name, or find a different symbol, we must try
a reverse hash search before giving up.
* txr.1: Add notes to use-sym-as that unuse-sym must be
used to undo its effect. Add notes to unuse-sym discussing
similarities and differences versus unintern.
* tests/012/use-as.tl: New test cases.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The new function use-sym-as can bring a foreign
symbol into a package under a different name,
which is not that symbol's name. This is also
featured in a new defpackage clause, :use-syms-as.
With this simple relaxation in the package system,
we don't require package local nicknames, which is
more complicated to implement and less ergonomic,
because it doesn't actually vanquish the use of
ugly package prefixes on clashing symbols.
* eval.c (eval_init): Register use-syms-as.
* lib.c (use_sym_as): New function, made out of
use_sym.
(use_sym): Now a wrapper for use_sym_as.
* lib.h (use_sym_as): Declared.
* stdlib/package.tl (defpackage): Implement :use-syms-as
clause.
* tests/012/use-as.tl: New file.
* txr.1: Documented,
* stdlib/doc-syms.tl: Updated.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* stdlib/op.tl (opip-expand): Take arguments which specify
the op and do operators to be inserted. Pass these
through the recursive calls.
(opip, oand): Pass op and do for the new arguments.
(lopip, loand): New macros like opip and oand, but
passing lop and ldo to the expander.
(lflow): New macro.
* autoload.c (op_set_entries): Add autoload entries
for lopip, loand and lflow.
* tests/012/op.tl: A few new tests.
* txr.1: Documented.
* stdlib/doc-syms.tl: Regenerated.
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* stream.c (close_stream): If the underlying method
returns the colon symbol :, then keep the cached
close_result as nil, so that the method can be called
again, but return t to the caller to indicate success.
* tests/018/close-delegate.tl: Test case added.
* tests/018/close-delegate.expected: Updated.
* txr.1: Documented.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This is motivated by trying to implement a struct delegate
stream which performs reference counting in close, in
order to close the real stream when the count hits zero.
The caching behavior of close-stream is a problem.
* stream.c (strm_base_init): Initialize close_result to nil,
rather than nao.
(strm_base_mark): Don't check close_result for nao.
(close_stream): Suppress the call to op->close if close_result
has a non-nil value, rather than a value other than nao.
* tests/018/close-delegate.tl,
* tests/018/close-delegate.expected: New files.
* txr.1: Document that only a non-nil return is cached
by close-stream.
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* stdlib/op.tl (sys:opip-single-let-p,
sys:opip-let-p): New functions.
(sys:opip-expand): Restructure from collect loop
to car/cdr recursive form, because the new let operators
in opip need access to the rest of the pipeline.
Implement let operators.
* tests/012/op.tl: New tests.
* txr.1: Documented.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This is a regression due to a March 2016 commit which
introduced the ability for :vars in an output-side @(repeat)
block to have initial values.
The bug has the effect that all arguments in @(repeat)
which are conses/lists get duplicated, which messes up
the property list structure.
* parser.y (expand_repeat_rep_args): Do not unconditionally
add reg to the output at the bottom of the loop. A few
cases above in the consp(arg) case handle that themselves, and
do not continue the loop, so control ends up at the bottom,
adding a spurious item. By removing this list_collect,
we have to introduce it to just one case which relies on it.
* tests/008/repeat.txr,
* tests/008/repeat.expected: New files.
* y.tab.c.shipped: Updated.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
When a pattern variable match like @foo references a global
symbol macro, that's treated as an existing expression to
match, and not a new binding. However, local symbol macros
are not treated this way; they are invisible to variable
patterns. That is an unintended inconsistency.
* stdlib/match.tl (var-list exists): Use lexical-binding-kind
rather than lexical-var-p. This returns true for lexical
symbol macros also.
* tests/011/patmatch.tl: New test cases.
* txr.1: Documentation revised to clarify that both global
and local symbol macros are considered to be existing variable
bindings by pattern matching.
|
|
|
|
|
|
| |
* tests/011/patmatch.tl: Move the form which compiles the
entire file to the end of the file, so that all the
interpreted test cases complete before we compile.
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* stdlib/path-test.tl (path-volume): Don't return
:abs for a path whose empty first component
isn't followed by any more items. Otherwise
we return :abs for a path formed by splitting
the empty string, and then calls like (rel-path "" "a")
complain about a mixture of absolute and relative.
With this change, empty paths given to rel-path
behave as if they were ".".
* tests/018/rel-path.tl: New test cases.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This commit does two things. The replace function, implemented
under the hood by four specializations: replace-list, replace-vec,
replace-str and replace-buf, will handle the index-list case
a little differently. This is needed to fix the ability of the
del macro work on place designated by an index list, such as:
(del [sequence '(1 3 5 6)]
which now deletes elements 1, 3, 5 and 6 from the sequence,
and returns a sequence of those items. The underlying
implementation uses replace with an index-list, which is now
capable of deleting items. Previously, replace would stop
processing the index list when the replacement-sequence
corresponding to the index list ran out of items. Now,
when the replacement-sequence runs out of items, the
remaining index-list sequence elements specify items to
be deleted. For instance if str holds "abcdefg" then:
(set [str '(1 3 5)] "xy")
will change str to "axcyeg". Elements 1 and 3 are replaced
by x and y, respectively. Element 5, the letter f, is
deleted, because the replacement "xy" has no element
corresponding to 5.
* lib.c (replace_list, replace_str, replace_vec): Implement
new deleteion semantics for the case when the replacement
sequence runs out of items.
* buf.c (replace_buf): Likewise.
* tests/010/seq.txr: Some new test cases here for
deletion.
* tests/010/seq.expected: Updated.
* txr.1: Documented new semantics of replace, including
a new restriction that if elements are being deleted,
the indices should be monotonically increasing regardless
of the type of the sequence (not only list).
A value of 289 for the -C option documented, which restores
the previous behavior of replace (breaking deletion by
index-list, unfortunately: you don't always get to
simulate an old version of TXR while using new features.)
|
|
|
|
|
|
|
|
| |
* eval.c (op_defsymacro, rt_defsymacro): We must call
vm_invalidate_binding so the VM forgets a cached binding
for this variable.
* tests/019/redef.tl: Test added.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
There was a bug in rt_defun in that it was not calling
vm_invalidate_binding. This mean that compiled functions
were not picking up redefinitions. This bug is fixed now
because rt_defun now calls sethash on the top_fb directly,
which modifies the existing binding cell; it is not
allocating a new cell.
We put in new test cases to confirm the proper redefinition
behaviors.
The proper redefinition behavior exposes an issue in
pattern matching.
* tests/019/redef.tl: New file.
* stdlib/match.tl (transform-quote): This function's compiled
image, when deposited into a .tlo file, becomes incorrect
because (sys:hash-lit) turns into #H() syntax, which reads
back as something else. In other words (sys:hash-lit)
deosn't have print-read consistency and so doesn't
externalize. To fix this right we would need a print mode
which ensures machine readability rather than human
readability, like in Common Lisp. For now, we just break up
the pattern so that it's not a literal match. This bug was
hidden due to theredefinition issue. When match.tl is
being compiled, it defines non-triv-pat-p twice. Due to
redefinitions not kicking in properly, the first definition
of non-triv-pat-p remains in effect for some functions.
When transform-qquote is being expanded, the (sys:hash-lit)
pattern is treated as non-trivial, even though it is
is trivial, and so it is turned into pattern matching code.
The code doesn't contain a (sys:hash-lit) literal and so
the issue doesn't occur.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The compiler handles trivial constant folding over the
source code, as a source to source transformation.
However, there are more opportunities for constant folding
after data flow optimizations of the VM code.
Early constant folding will not fold, for instance,
(let ((a 2) (b 3)) (* a b))
but we can reduce this to an end instruction that returns
the value of a D register that holds 6. Data flow optimizations
will propagate the D registers for 2 and 3 into the gcall
instruction. We can then recognize that we have a gcall with
nothing but D register operands, calling a constant-foldable
function. We can allocate a new D register to hold the result
of that calculation and just move that D register's value
into the target register of the original gcall.
* stdlib/compiler.tl (compiler get-dreg): When allocating
a new D reg, we must invalidate the datavec slot which is
calculated from the data hash. This didn't matter before,
because until now, get-datavec was called after compilation,
at which point no new D regs will exist. That is changing;
the optimizer can allocate D regs.
(compiler null-dregs, compiler null-stab): New methods.
(compiler optimize): Pass self to constructor for basic-blocks.
basic-blocks now references back to the compiler.
At optimization level 5 or higher, constant folding can
now happen, so we call the new method in the optimizer to
null the unused data. This overwrites unused D registers
and unused parts of the symbol vector with nil.
* stdlib/optimize (basic-blocks): Boa constructor now takes
a new leftmost param, the compiler.
(basic-blocks do-peephole-block): New optimization case:
gcall instruction invoking const-foldable function, with
all arguments being dregs.
(basic-blocks null-unused-data): New method.
|
|
|
|
| |
* tests/013/chksum.tl: New file.
|
|
|
|
|
|
|
|
|
| |
* lib.c (dwim_set): Handle seq argument being an integer
or range.
* tests/012/callable.tl: A few tests.
* txr.1: Documented.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* lib.c (do_generic_funcall): Allow integers and ranges
to be function callable. They take one argument and
index into it or extract a slice. In the case of ranges,
this is a breaking change. Ranges can already be used
in the function position in some limited ways that are
not worth preserving.
* tests/012/callable.tl: New file.
* tests/012/iter.tl: Here we fix two instances of
breakage. Using txr -C 288 will restore the
behaviors previously tested here.
* txr.1: Documented.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
These functions are useful when sorting a sequence
using an expensive keyfun.
* autoload.c (csort_set_entries, csort_instantiate):
New static functions.
(autlod_init): Register autoloading of csort module
via new functions.
* stdlib/csort.tl: New file.
* tests/012/sort.tl: csort functions included in tests.
* txr.1: Documented.
* stdlib/doc-syms.tl: Updated.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
hash-map converts a function mapping over a sequence
into a hash table.
* hash.[ch] (hash_map): New function.
* tests/010/hash.tl: Test case.
* genman.txr: The hash-map identifier introduces
a hash collision. We have to deal with that somehow now.
(colli): We put the conflicting entries into a new hash called
colli which maps them to an increment value.
(hash-title): Increment the hash code h by the amount
indicated in colli, if the title is found there.
* txr.1: Documented.
* stdlib/doc-syms.tl: Updated.
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* lib.c (equal): Several cases which react to the
type of the left argument have a default path which
wrongly short-circuits to an early return.
All these cases must break through to the logic
at the end of the function which tests the right side
for a possible equality substitution.
* tests/012/struct.tl: One breaking test cases added.
equal was found to return nil for two structures
that have equal lists as their equality substitute.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The original chained hashing scheme makes certain
guarantees in situation when a hash table that is being
iterated is also undergoing insertions or deletions.
The original scheme meets these requirements simply,
by putting a freeze against hash table growth while
there are outstanding iterations. Chained hashing
gracefully handles load factors above 1.
Load factors above 1 are not possible under open
addressing (and we don't even want to approach 1)
but we would like to preserve the requirements.
The requirements are:
1. If an iterator has already visited an item, it
will not see that item again, regardless of insertions
which cause the table to be reorganized.
2. It is not specified/required that an iterator will
visit newly inserted items. It may visit some of those
items, but not others.
3. If an iterator has not yet visited an item, and
that item is deleted, it will not see that item,
regardless of any insertions that reorganize the table.
In this commit, we implement a "table stack" scheme.
1. When a table is resized due to insertions, and
it is being iterated (h->usecount > 0), in that situation
it will push the existing small table onto a stack,
the h->tblstack (table stack).
2. Iterators take a hash table's current table and its
size, and work with that snapshot of the table.
If the original hash table grows, existing iterators
work with the original table as it existed just before
the reorganization. So after that they do not see any
new insertions.
3. Whenever the delete operation (hash_remove) finds
the item and removes it from the current table,
it also walks the table stack, searches for the item
in every table in the stack and nulls it out.
This search is oblivious to nil; it's a blind search
that goes around the table starting at the first
probe position, looking for the identical cons cell
to take out. This algorithm ensures that iterators
will not see a deleted item, unless they already visited
it before the deletion, of course.
* hash.h (struct hash_iter): New members table, and mask.
* hash.c (struct hash): New member, tblstack.
(hash_grow): We drop the vec argument and recreate it
locally (not essential to this commit).
If we find that the usecount is positive, we push the
existing table onto the table stack. Otherwise,
we take the opportunity to obliterate the table stack.
(hash_insert): Drop the restriction that hash_grow is
only called when the use count is zero. Adjust calls
to hash_grow to drop the vec argument.
(hash_remove): When an item is found and deleted, and
the table is in use by iterators, walk the table stack
and delete it from each previous table. Otherwise,
if the table is not in use by iterators, obliterate
the table stack.
(hash_mark): Exit early also if there is a table stack,
and mark that stack.
(do_make_hash, make_similar_hash, copy_hash): Initialize
table stack in new hash.
(hash_iter_mark): Mark the iterator's table. This is
likely not necessary since we also mark the hash table,
which should have a pointer to that same table.
That wouldn't be defensive programming, though.
(hash_iter_init, us_hash_iter_init): Initialize table and mask.
(hash_iter_next_impl, hash_iter_peek): These functions
have to walk the table snapshot taken by the iterator,
using the captured mask, and not the current table.
(has_reset): If the target table's use count drops to zero,
obliterate its table stack. We add a missing setcheck here;
this operation potentially stores a different hash into
an existing iterator. It's not being done safely with
regard to generational GC.
* tests/010/hash.tl: New tests.
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* stdlib/match.tl (match-cond): New macro.
* autoload.c (match_set_entries): match-cond triggers
autoload of match module.
* tests/011/patmatch.tl: Tests.
* txr.1: Documented.
* stdlib/doc.tl: Updated.
|
|
|
|
|
|
|
|
|
|
|
| |
* lib.[ch] (keep_keys_if, separate_keys): New functions.
* eval.c (eval_init): keep-keys-if, separate-keys intrinsics
registered.
* txr.1: Documented.
* stdlib/doc-syms.tl: Updated.
|
|
|
|
|
|
| |
* tests/018/clean.tl: New file.
* tests/018/clean.expected: New file.
|
|
|
|
|
|
|
|
|
|
|
|
| |
* autoload.c (load_args_set_entries, load_args_instantiate):
New static functions.
(autoload_init): Register new auto-loaded module "load-args".
* stdlib/load-args.tl: New file.
* txr.1: Documented.
* stdlib/doc-syms.tl: Updated.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
We can give additional arguments to load, which
become arguments of the script, which it can
retrieve via the *load-args* special variable.
* eval.c (load_args_s): New symbol variable.
(loadv): New function, taking over the
implementation of load. This takes variadic
arguments. Loadv binds the *load-args* variable
from the list of variadic arguments.
(load): Reduced to wrapper around loadv.
(rt_load_for): Each clause in load for can
now have arguments after the target name. If
that file needs to be loaded, then the arguments
are passed.
(me_load_for): The macro expander for the load-for
macro needs to allow for the load-arg expressions
and generate code which passes them to sys:rt-load-for.
They all get evaluated.
(eval-init): Initialize load_args_s and register the
*load-args* variable. Update registration of intrinsic
function load to use loadv.
* tests/019/load-ret.tl,
* tests/019/load-ret/module.tl,
* tests/019/load-ret/module2.tl:
New files.
* txr.1: Documented.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Parameter list macros work in inside macro parameter lists,
like they do in function parameter lists. However, they
ony work at the top level. Macro parameter lists are nested;
they may contain nested parameter lists that match
corresponding shapes in the argument list.
This patch extends parameter list macros to work in
nested macro parameter lists.
* eval.c (expand_opt_params_rec, expand_params_rec):
These two functions must be extended to take a body
argument, and to return not just an expanded parameter
list but a parameter list accompanied by a body.
We do that by making them return a cons cell, whose
car is the expanded parameter list and the cdr is
the possibly transformed body. Additionally, these
functions now call expand_param_macro on nested
macro parameter lists.
(expand_params): This function becomes slightly simpler
as a result of the above changes. Because expand_params_rec
already returns a cons cell holding a parameter list and
body, we just return that as-is.
* tests/011/keyparams.tl: Added some tests of this, vie the
standard :key parameter list macro. A macro is tested
which has a nested (:key ...) parameter list in a required
parameter position as well as in an optional position.
* txr.1: Documented.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* eval.c (make_var_shadowing_env): We cannot return the
original env in the empty variable case, but earnestly
make a new one. This function is used by the expander when
walking the lbind/fbind special from emitted by labels/flet.
That form clobbers the environment via make_fun_shadowing_env,
which calls make_var_shadowing_env and then destructively
moves the variable bindings to the function binding slot of
the environment. The manifestation is that when we have
(symacrolet ((x 1)) (labels () x)), the x fails to expand; it
has been wrongly moved to the function bindings area of the
macro environment.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The functions funcall1 through funcall4, when invoking a VM
function, are not defending against the case when there
are more arguments than the function can take.
As a result, some :mass-delegate tests in tests/012/oop.tl
are failing. They expect an :error result, but the calls
are succeeding in spite of passing too many parameters
via the delegate interface.
The tests/012/lambda.tl suite should catch this, but
it has unfortunate weaknesses.
* lib.c (funcall1, funcall2, funcall3, funcall4):
When dispatching the general VM case via
vm_execute_closure, check that if the closure has
fewer fixed parameters than arguments we are passing,
it must be variadic, or else there is an error.
* tests/012/lambda.tl (call-lambda-fixed): New function.
Unlike call-lambda, which uses the apply dot syntax,
this switches on the argument list shape and dispatches
direct calls. These compile to the CALL instruction
cases with four arguments or less which will exercise
funcall, funcall1, ... funcall4. Also, adding some missing
test cases that probe behavior with excess arguments.
|
|
|
|
|
|
|
| |
* stdlib/awk.tl (awk-state ensure-stream): Fix missing
handling for the :apf kind symbol used by appending.
* tests/015/awk-redir.tl: New file.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Adding a progv operator, similar to the Common Lisp one.
* eval.c (progv_s): New symbol variable.
(op_progv): New static function.
(do_expand): Recognize and traverse the progv form.
(rt_progv): New static function: run-time support
for compiled progv.
(eval_init): Initialize progv_s, and register the the
op_progv operator interpreting function.
* stdlib/compilert (compiler compile): Handle progv
operator ...
(compiler comp-progv): ... via this new method.
* tests/019/progv.tl: New file.
* txr.1: Documented.
* stdlib/doc-syms.tl: Updated.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
We have a problem. If v is a dynamic variable, then
the form
(let (v)
(set (symbol-value 'v) 3))
is not behaving correctly; it's updating the top-level
value of v not the rebound one.
* eval.c (set_symbol_value): New static function.
(eval_init): Register sys:set-symbol-value intrinsic.
The top-vb variable, though no longer referenced by
the symbol-value place, because existing compiled
code depends on it.
* stdlib/place.tl (symbol-value): Rewrite the place
logic to use symbol-value to access the variable,
and set-symbol-value to update it, instead of referencing
sys:top-vb.
(sys:get-vb): This function has to stay, because it
provides run-time support for code compiled with the
buggy version of the place.
* tests/019/symbol-value.tl: New file.
|
|
|
|
|
|
|
| |
* tests/012/sort.tl: The larger input tests are
testing only vectors, thus covering neither
quicksort nor array binary merge. Cases
added.
|
|
|
|
|
|
|
|
| |
* tests/010/sort.tl: File moved to tests/012.
The reason is that the tests 010 run with the
--gc-debug torture tests. That test case runs
way too long under that test because of the
testing of many permutations and whatnot.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
For array-like objecgts, these objects use an
array-based merge sort, using an auxiliary array
equal in size to the original array.
To provide the auxiliary array, a new kind of very simple
vector-like object is introduced into the gc module: protected
array. This looks like a raw dynamic C array of val type,
returned as a val *. Under the hood, there is a heap object
there, which makes the array traversable by the garbage
collector.
The whole point of this exercise is to make the new mergesort
function safe even if the caller-supplied functions misbehave
in such a way that the auxiliary array holds the only
references to heap objects.
* gc.c (struct prot_array): New struct,
(prot_array_cls): New static variable.
(gc_late_init): Register COBJ class, retaining in
prot_array_cls.
(prot_array_mark, prot_array_free): New static functions.
(prot_array_ops): New static structure.
(prot_array_alloc, prot_array_free): New functions.
* gc.h (prot_array_alloc, prot_array_free): Declared.
* lib.c (mergesort, ssort_vec): New static function.
(snsort, ssort): New functions.
* lib.h (snsort, ssort): Declared.
* tests/010/sort.tl: Cover ssort.
* txr.1: Documented.
* stdlib/doc-syms.tl: Updated.
|
|
|
|
|
|
|
|
| |
* tests/010/sort.tl: Add some test cases of larger list.
The exhaustive permutation tests are good but only go
up to a relatively short size, where the median-of-three
doesn't even kick in. We also cover choosing an alternative
less function.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
I'm seeing numbers aobut the same performance on a
sorted vector of integers, and 21% faster on vector of N
random integers in the range [0, N).
Also, this original algorithm handles well the case
of an array consisting of a repeated value.
The code we are replacing degrates to quadratic time.
* lib.c (med_of_three, middle_pivot): We don't use
the return value, so don't calculate and return one.
(quicksort): Revise to Hoare: scanning from both ends
of the array, exchanging elements.
* tests/010/sort.tl: New file. We test sort with
lists and vectors from length zero to eight, all
permutations.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
We don't have a function in the hash table module which can
create a populated hash table in one step without requiring
the caller to create auxiliary lists. This new function fills
that gap, albeit with some limitations.
* hash.c (hash_props): New function.
(hash_init): Register hash-props intrinsic.
* tests/010/hash.tl: New tests.
* txr.1: Documented.
* stdlib/doc-syms.tl: Updated.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Quasiquote patterns not containing unquotes are not
working, because the parser transforms them into
quoted objects. For instance ^#S(time) becomes
the form (quote #S(time)) and not the
form (sys:qquote (sys:struct-lit time)).
The pattern matching compiler doesn't treat quote
specially, only sys:qquote.
* parser.y (unquotes_occur): Function removed.
(vector, hash, struct, tree, json_vals, json_pairs):
Remove use of unquotes_occur. Thus vector, hash,
struct, tree and JSON syntax occurring within a
backquote will be turned into a special literal
whether or not it contains unquotes.
* lib.c (obj_print_impl): Do not print the
form (sys:hash-lit) as #Hnil, but #H().
* stdlib/match.tl (transform-qquote): Add a case
which will handle ^#H(), as if it were ^H(()).
Bugfix in the ^H(() ...) case. The use of @(coll)
means it fails to match the empty syntax when
no key/value pairs are specified, whereas
@(all) respects vacuous truth.
* test/011/patmatch.tl: A few tests.
* y.tab.shipped, y.tab.h.shipped: Updated.
|
|
|
|
| |
* tests/010/range.tl: New file.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* lib.h (arithp): Declared.
(plus_s): Existing symbol declared.
* arith.c (arithp): New function.
* struct.h (special_slot): New enum member plus_m.
* struct.c (special_sym): Register plus_s together as
the [plus_m] entry of the array.
* tests/016/arith.tl
* tests/016/ud-arith.tl: Tests for arithp.
* txr.1: Documented.
* stdlib/doc-syms.tl: Updated.
|