| Commit message (Collapse) | Author | Age | Files | Lines |
... | |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Implement a mechanism for extracting keyword arguments out of
"struct args *" argument lists which avoids consing up an
argument list and scanning it multiple times for multiple
keywords.
* args.c (args_for_each): New function.
(struct args_bool_key, struct args_bool_ctx): New struct
types.
(args_key_check_store): New static function.
(args_keys_extract_vl, args_key_extract): New functions.
* args.h (args_for_each, args_keys_extract_vl,
args_key_extract): Declared.
|
|
|
|
|
|
| |
* lib.c (mapcar_listout): Rework using seq_info for
efficient processing of vector-like sequences and
objects that implement sequences.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
When a form is a macro, but the macro declines to expand the
form, the form must still be code walked; we can't just return
it and be done. For instance if it is a function call, its
argument expressions have to be expanded.
This also causes undefined function warning to be generated
properly if a macro declines, and the resulting form is
a function call to a not-yet-defined function.
* eval.c (do_expand): If expand_macro yields the original
form, branch backwards to re-execute the whole if statement
again. Use the fact that the local variable macro is now
non-nil to skip the macro expansion case.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This patch implements a new requirement which clarifies what
happens when a macro declines to expand a form.
To decline expanding a form means to return the original form
(same object) without returning it. The expander detects this
situation with an eq comparison on the input and output.
The current behavior is that no further attempts are made to
expand the form. This is problematic for various reasons. In
code which is expanded more than once, this can lead to the
expansion being different between the expansion passes. In
the first pass, a local macro M might decline to expand a
form. In the second pass, the local macro definition no longer
exists, and the form does get expanded by a global macro M.
This kind of instability introduces a flaw into complex macros
which expand their argument material more than once.
The new requirement is that if a macro definition declines to
expand a macro, then a search takes place through the outer
lexical scopes, and global scope, for the innermost macro
definition which will expand the form. The search tries every
macro in turn, stopping if a macro is found which doesn't
decline the expansion, or after passing the global scope.
* eval.c (expand_macro): Implement new searching behavior.
* txr.1: Documented the expansion declining mechanism
under defmacro and macrolet.
* tests/011/macros-3.tl: New file.
* tests/011/macros-3.expected: New file.
|
|
|
|
|
|
|
|
|
| |
* lib.c (unsup_obj): New static function.
(grade, find, rfind, find_max, find_if, rfind_if, pos, rpos,
pos_if, rpos_if, pos_max): Replace call to uw_throwf with call
to unsup_obj. IN all these functions except grade, the ~s
conversion specifier was wrongly used on the function name
rather than ~a, resulting in unwanted quoting.
|
|
|
|
|
|
|
|
|
|
|
|
| |
Inspired by APL.
* eval.c (eval_init): Register grade intrinsic.
* lib.c (grade): New function.
* lib.h (grade): Declared.
* txr.1: Documented.
|
|
|
|
|
| |
* lib.c (lastcons): Don't wastefully call cdr on an object
after called cdr_l; just dereference the cdr_l loc.
|
|
|
|
|
|
|
|
|
|
|
| |
* lib.c (tail): This low-level function is used by the
list accumulation routines. Because it doesn't handle
improper lists, looking for a null terminator, certain
things don't work, like the associativity of append.
For instance (append '(1 2) #(3) 4) works but not
(append (append '(1 2) #(3)) 4). Fixing tail so that it
terminates on any atom, rather than failing trying to
cdr through it.
|
|
|
|
|
|
|
| |
* txr.1: Documentation for append and nconc is rewritten.
Treatment of non-list sequences is explained in detail.
Description of append* is split off into its own section,
because its handling of non-lists is too different.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Two bugs in these functions, both attributable to
the lazy_appendv implementation:
They destructively catenate the input lists,
much like nconc, even though documented as
non-destructive.
If any input list is infinite, other than the
last input list, that list is forced, resulting
in an infinite loop.
* lib.c (lazy_appendv_func): Rewritten to use a
different algorithm which earnestly allocates a
new lazy cons for each element of the output
sequence, except for the tail part corresponding
to the last list.
(lazy_appendv): Set up the lazy cons according
to the new representation and just return it.
No searching for the tail of the nonempty list,
and no destructive manipulation.
|
|
|
|
|
|
|
|
|
|
| |
* RELNOTES: Updated.
* configure, txr.1: Bumped version and date.
* share/txr/stdlib/ver.tl: Likewise.
* txr.vim: Regenerated.
|
|
|
|
|
|
| |
* txr.1: mention that the rightmost maximum can be found by
manipulating the comparison function. (Hence, this is why
we don't provide rpos-max and rfind-max).
|
|
|
|
|
|
|
|
|
|
|
| |
* lib.c (find, rfind, find_max, find_if, rfind_if, pos, rpos,
pos_if, rpos_if, pos_max): Consistently fixnum indices for
iterating over vector. In some functions, a cnum is already
used, but could be out of fixnum range; we switch to using
c_fixnum for extracting the length and then num_fast on the
index. Some functions are converted from using a val index.
In the case of rfind_if, a bug is fixed: it was using plusp,
which now becomes the correct >= 0.
|
|
|
|
| |
* lib.c (pos_max): Rewrite using seq_info.
|
|
|
|
|
|
| |
* lib.c (find_max): Fix a regression introduced
in recent work: only execute the loop when the vector isn't
empty.
|
|
|
|
| |
* lib.c (pos_if, rpos_if): Rewrite using seq_info.
|
|
|
|
|
|
|
| |
* lib.c (posq, posql, posqual, rposq, rposql, rposqual): These
functions are reduced to wrappers around pos and rpos,
respectively, so they generalize properly and efficiently
to sequences of all kinds.
|
|
|
|
|
|
|
| |
* lib.c (pos, rpos): Functions rewritten to use the seq_info
sequence classification mechanism. The rpos function is
thereby optimized to work with vectors. Both functions support
vector-like struct objects now.
|
|
|
|
|
|
|
|
|
|
| |
* lib.c (rfind_if): Function rewritten to use the seq_info
sequence classification mechanism, for much better
performance on vector-like objects. Also, supports hash
tables just like find_if.
* txr.1: Documentation updated regarding hash support
of rfind-if.
|
|
|
|
|
|
|
|
|
|
| |
* lib.c (find_if): Function rewritten to use the seq_info
sequence classification mechanism, for much better
performance on vector-like objects. Also, supports hash
tables just like find_max.
* txr.1: Documentation updated regarding hash support
of find-if.
|
|
|
|
|
|
| |
* lib.c (find_max): The vector case must loop from
index one, not zero, so as not to wastefully compare the
initial max element to itself.
|
|
|
|
|
| |
* txr.1: Behavior of subtypep is not specified if either
argument isn't a type.
|
|
|
|
|
| |
* share/txr/stdlib/awk.tl (sys:awk-mac-let): A few occurrences
of the deprecated set-diff function are replaced with diff.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Currently, using "rb" in open-command reports an error on
GNU/Linux, due to popen not liking the "b" mode.
On Cygwin, the "b" flag is useful with popen.
* stream.c (normalize_mode_no_bin): New function.
(open_command): Use normalize_mode_no_bin instead of
normalize_mode to strip out the binary flag.
This doesn't happen on Cygwin, though.
* stream.h (normalize_mode_no_bin): Declared.
* share/txr/stdlib/getput.tl (command-get-buf): Since
we are getting binary data, pass the "rb" mode to
open-command, now that it works.
(command-put-buf): Add "b" flag to mode passed
to open-command.
|
|
|
|
|
| |
* txr.1: fix awkward wording which applies the definite
article "the" to a Lisp expression.
|
|
|
|
| |
* txr.1: Streams support put-byte, not buffers.
|
|
|
|
| |
* genvim.txr (iskeyword): add % character.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* share/txr/stdlib/awk.tl (sys:awk%--rng, sys:awk%--rng-,
sys:awk%rng+, sys:awk%-rng+, sys:awk%--rng+): New functions.
(sys:awk-mac-let): Rewritten range expander. The four basic
ranges rng, rng-, -rng and -rng- are handled with in-line
expansion, because by doing that we avoid unnecessarily
evaluating the from-expression. The remaining cases expand
to function calls to the new functions, which receive the
flag vector, the index position in that vector and the values
of the from and to expressions. The behavior change is that
that the -- forms now do the right thing: they hide all
leading records that satisfy the from-expression, right to the
last record of the range if necessary.
* tests/015/awk-rng.expected: Updated.
* txr.1: Revise semantic description the -- range types, plus
minor fixes.
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* lisplib.c (getput_set_entries): New autoload entries for
file-get-buf, file-put-buf, file-append-buf, command-get-buf
and command-put-buf.
* share/txr/stdlib/getput.tl (sys:get-buf-common): New
function.
(file-get-buf, file-put-buf, file-append-buf, command-get-buf,
command-put-buf): New functions.
* txr.1: Documented.
|
|
|
|
|
|
| |
* tests/015/awk-rng.tl: More rows of data.
* tests/015/awk-rng.expected: Updated.
|
|
|
|
|
|
|
|
|
|
|
|
| |
The problem is that when records appear in the middle
of the range which again match from-expr, they
get suppressed.
* share/txr/stdlib/awk.tl (sys:awk-mac-let): Get rid of the
flag-mid variable. It cannot work because middle is a state
in its own right that cannot be inferred from the existing
states (nil, t, :end) and the value of from-expr. We get rid
of the flag and introduce a :mid state value.
|
|
|
|
|
|
|
| |
* ffi.c (carray_blank, carray_buf, carray_cptr, carray_pun):
these functions should be using ffi_type_struct_checked,
since they are public interfaces to which anything can be
passed. Otherwise TXR can easily be crashed by misusing them.
|
|
|
|
|
|
| |
* ffi.c (carray_ref): If the index is negative,
displace it by the length of the array. (Then if
it is still negative, the function will throw.)
|
|
|
|
| |
* txr.1: rr searches for "a match" not "a matches".
|
|
|
|
|
|
| |
* txr.1: Fix bungled formatting of third argument
alternatives in the syntax synopsis of the
partition function.
|
|
|
|
|
|
|
|
| |
* share/txr/stdlib/op.tl (sys:op-expand): Throw error if
argument list is empty. We refer to the compile-error
function by quote to avoid triggering the auto-load of
the module which defines it, due to the circular dependency
on op.
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The code is using a non-hygienic variable called flag
as a placelet alias. This binding is visible to range
expressions. For instance (rng #/x/ flag) actually
references the range expression's internal flag, rather
than producing a warning about an unbound variable.
* share/txr/stdlib/awk.tl (sys:awk-mac-let): Allocate a gensym
for the flag. Then use ,flag throughout the code templates
rather than flag to insert the gensym wherever the symbol
flag previously appeared.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This is an improvement in the code generation related
to awk range expressions. Previously, on each iteration,
for each range expression, the awk state structure is
accessed to retrieve the flag vector, which is then kept
in a lexical variable. With this change, the retrieval
is done once for all the range expressions, which share
the same variable to access it.
* share/txr/stdlib/awk.tl (sys:awk-compile-time): New slot,
rng-vec-temp.
(sys:awk-mac-let): Alias the flag variable to a simplified
vecref expression which accesses the vector assumed to
have been retrieved and bound to the variable named by
the rng-vec-temp gensym.
(awk): Add one more variable binding into the scope of
the ranges: the binding of the variable named by the
rng-vec-temp gensym, to an expression which retrieves the
rng-vec from the Awk run-time state structure.
|
|
|
|
|
|
|
|
|
|
|
|
| |
* share/txr/stdlib/awk.tl (sys;awk-mac-let): Provide the
implementation for the local macros --rng, --rng-,
rng+, -rng+ and --rng+.
* tests/015/awk-rng.tl: New file.
* tests/015/awk-rng.expected: New file.
* txr.1: Documented.
|
|
|
|
|
|
|
|
|
|
| |
* eval.c (me_case): When a list of case keys is one
element long, reduce it to an atom. Then a simple
equality is applied whether the item is equal
to the key, rather than whether it is a member
of a list containing that one key.
This helps with the (t) case which is mandatory,
since t is ruled out as a key.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The problem is that if a test is interrupted, it will not be
re-run because the .ok stamp file depends only on an .out
file, and that has been successfully created.
We completely remove .out files from the rule tree. Quite
simply, the output of a test is the .ok stamp. If that is
out of date or doesn't exist, the test is run. Generation
of the .out is just a side effect.
* Makefile (TESTS_OK): Calculate this variable directly from
the wildcard over .txr and .tl files..directly rather than
from TESTS_OUT.
(TESTS_OUT): Variable removed.
(TXR_OPTS, TXR_ARGS): The target-specific assignments of
these variables for specific tests is now done against .ok
stamp file targets rather than .out targets.
(TST_EXPECTED, TST_OUT): New helper variables for condensing
repeated instances of some syntax.
(tst/%.out): Both of these rules are turned into rules
which target tst/%.ok. The .out files are just a side effect;
the goal is to update the stamp. If an .out file is removed,
the test won't be re-run; only if an .ok file is removed,
or any of the real prerequisites change.
(%.ok): This rule disappears, and its body containing the
conditional stamp file touch is moved into both tst/%.ok
rules.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Last I addressed this, I didn't get it quite right. The
problem is that the .out files are being removed when a test
fails, which is annoying. The whole redirection of test
results to a temp file which is then renamed is silly.
Now, the .out files are preserved. Whether or not a test
passed depends on whether or not the .ok stamp file is created
or updated, so it doesn't matter whether an .out file exists
or not.
Also, tests are made dependent on the executable, and on
the .expected files. If the executable is newer than the test
outputs, all the tests will re-run. Also, if any .expected
file is touched, the corresponding test will be re-run.
* Makefile (clean): Do not remove $(TESTS_TMP).
(TESTS_TMP): Variable removed.
(tst/%.out): In both rules that run the test and make .out
files simply redirect the output directly to the .out file
represented as the $@ target. This is how it was before,
once upon a time.
(%.ok): Do not remove the .out file represdented by $<
if the test fails; it is sufficient not to create/touch
the .ok stamp file.
|
|
|
|
|
|
|
|
|
|
|
|
| |
For all build steps other than linking, print only the
leftmost prerequisite of the target.
* Makefile (ABBREV): The macro references $< rather than $^,
and hence longer needs the $(DEP_$@) filtering.
(ABBREVN): New macro, identical to previous ABBREV,
modulo a whitespace fix: removal of a stray tab character.
(LINK_PROG): For linking, use ABBREVN so that all the object
files are shown.
|
|
|
|
|
|
|
|
|
|
|
|
| |
* hash.c (remhash): Walk chain to splice out to-be-removed
entry using an approach similar to what is done in
do_weak_tables to splice out lapsed weak entries. This
eliminates one extra traversal of the chain as well as consing
due to the ldiff call. We use raw pointers obtained using
valptr, and direct assignment through *pchain because later
cells in a chain are strictly older objects than earlier
cells and so so the *pchain = cdr(*pchain) assignment cannot
make a generation 1 object point to a generation 0 object.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Impact assessment: this bug affects the correctness of
all programs which rely on copying hash tables. Direct
reliance means the use of copy-hash, or using the generic copy
function on hash objects. Indirect reliance occurs through
hash-diff which uses copy-hash. Nothing in TXR itself calls
hash-diff. The the listener's Tab completion relies on
copy-hash for package-sensitive symbol visibility calculation.
Since that is an interactive feature, the impact is low.
* hash.c (copy_hash_chain): New static function.
(copy_hash): Use copy_hash_chain instead of copy_alist,
since the pairs are hash conses and not regular conses:
they have a hash value field that must be copied.
|
|
|
|
|
|
|
| |
* hash.c (hash_assoc, hash_assql): Remove useless nullify
calls. These are copy and paste leftovers, since these
functions were based on assoc and assql, which handle
sequences other than lists.
|
|
|
|
|
|
|
|
|
|
| |
* lisplib.c (op_set_entries): Add lop to auto-load list.
* share/txr/stdlib/op.tl (sys:op-expand): Recognize lop
and implement its transformation.
(lop) New macro.
* txr.1: Documented.
|
|
|
|
|
|
|
| |
* lib.c (find_max): Sequence classification rewritten to use
seq_info. The cases are almost the same, but refer to si.obj
rather than seq. Some care is taken in the list case to not
hold a reference to the list head.
|
|
|
|
|
|
| |
* lib.c (rfind): Instead of treating the sequence as a list,
classify with seq_info just like find. Basically the whole
function is replaced with an altered copy of find.
|
|
|
|
|
|
|
| |
* lib.c (find): Convert switch statement to use the seq_info
function to classify the sequence. For SEQ_VECLIKE,
we still check whether the original object is a literal
or regular string to treat it specially.
|