| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* lib.c (seq_iterable): Return t if argument is a structure
supporting the iter-begin method.
(seq_iter_get_oop, seq_iter_peek_oop, seq_iter_get_fast_oop,
seq_iter_peek_fast_oop): New static functions.
(seq_iter_init_with_info): Handle COBJ case. If the COBJ is a
structure which suports the iter-begin method, then retrieve
the iterator object by calling it, and then prepare the
iterator structure for either the fast or the canonical
protocol based on whether the iterator supports iter-more.
(seq_iter_mark): Mark the iter member if the iterator is a
struct object.
(iter_begin): Rearrange tests here to check object type first
before sequence kind. If the object is a structure supporting
the iter-begin method, then call it and return its value.
(iter_more, iter_step): Check for struct object with
corresponding special methods and return.
(iter_reset): Similar change like in iter_begin. We check for
the iter-reset special method and try to use it, otherwise
fall back on the regular iter_begin logic.
* lib.h (struct seq_iter): New member next of the ul union
for caching the result of a peek operation.
* struct.c (iter_begin_s, iter_more_s, iter_item_s,
iter_step_s, iter_reset_s): New symbol variables;
(special_sym): Pointers to new symbol variables added to
array.
(struct_init): New symbol variables initialized.
(get_special_required_slot): New function.
* struct.h (iter_begin_s, iter_more_s, iter_item_s,
iter_step_s, iter_reset_s): Declared.
(enum special_slot): New enum members iter_begin_m,
iter_more_m, iter_item_m, iter_step_m, iter_reset_m.
(get_special_required_slot): Declared.
* txr.1: Documented.
* tests/012/oop-seq.expected: New file.
* tests/012/oop-seq.tl: New file.
|
|
|
|
| |
* txr.1: article missing: "satisfies [the] predicate function".
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* lib.c (seq_iter_rewind, seq_iter_init_with_info): Reverse
the order in which we perform some type tests. We check for
some special types first, and then for the sequence kind.
These situations are mutually exclusive now, so the order
doesn't matter. The plan is to introduce the ability for a
structure object to be iterable with special methods. Such an
object won't necessarily be a sequence (seq_info may identify
it as SEQ_NOTSEQ). This code will be prepared for it becuase
it's now checking for the type first, before the sequence
kind.
|
|
|
|
|
|
|
|
|
|
|
|
| |
* eval.c (eval_init): Register iterable intrinsic.
* lib.c (seq_iterable): New static function.
(nullify): Use seq_iterable to simplify function.
(iterable): New function.
* lib.h (iterable): Declared.
* txr.1: Documented.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* struct.c (slot_types): Try lisplib_try_load, just like in
static_slot_types. The reason for this is that there is code
like (or (sys:slot-types slot) (sys:static-slot-types slot))
which occurs in sys:check-slot, testing both hashes. This
code gets fooled in the following way: the sys:slot-types slot
reports nil for a particular slot being probed. It doesn't try
autoloading, checking the hash just once. Next,
sys:static-slot-types is called and triggers an autoload. The
autoload instantiates the slot as an instance slot (but not as
a static slot). Then sys:static-slot-types returns nil
also because there is no such static slot. The effect is that
the slot exists due to the autload, but since both functions
yielded nil, the overall (or ...) expression yields nil, which
is interpreted as the slot not existing.
|
|
|
|
|
| |
* struct.c (struct_init): Delete uselessly repeated statement
that generates a garbage hash object.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This allows a CRC-32 calculation over multiple objects in
multiple steps.
* chksum.c (crc32_stream, crc32_buf, crc32_str, crc32): Take
additional argument.
(chksum_init): Add optional argument to registration of
crc32-stream and crc32 intrinsics.
* chksum.h (crc32_stream, crc32): Declarations updated.
* txr.1: Doc updated; two examples added.
|
|
|
|
| |
* buf.c (uint_buf): Copy and paste from int_buf fixed.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The c_num and c_unum functions now take a self argument for
identifying the calling function. This requires changes in a
large number of places.
In a few places, additional functions acquire a self
argument. The ffi module has the most extensive example of
this.
Some functions mention their name in a larger string, or have
scattered literals giving their name; with the introduction of
the self local variable, these are replaced by references to
self.
In the following changelog, the notation TS stands for "take
self argument", meaning that the functions acquires a new "val
self" argument. The notation DS means "define self": the functions
in question defines a self variable, which they pass down.
The notation PS means that the functions pass down an existing
self variable to functions that now require it.
* args.h (args_count): TS.
* arith.c (c_unum, c_num): TS.
(toint, exptv): DS.
* buf.c (buf_check_len, buf_check_alloc_size, buf_check_index,
buf_do_set_len, replace_buf, buf_put_buf, buf_put_i8,
buf_put_u8, buf_put_char, buf_put_uchar, buf_get_bytes,
buf_get_i8, buf_get_u8, buf_get_cptr,
buf_strm_get_byte_callback, buf_strm_unget_byte, buf_swap32,
str_buf, buf_int, buf_uint, int_buf, uint_buf): PS.
(make_duplicate_buf, buf_shrink, sub_buf, buf_print,
buf_pprint): DS.
* chskum.c (sha256_stream_impl, sha256_buf, crc32_buf,
md5_stream_impl, md5_buf): TS.
(chksum_ensure_buf, sha256_stream, sha256, sha256_hash,
md5_stream, md5, md5_hash): PS.
(crc32_stream): DS.
* combi.c (perm_while_fun, perm_gen_fun_common,
perm_str_gen_fun, rperm_gen_fun, comb_vec_gen_fun,
comb_str_gen_fun, rcomb_vec_gen_fun, rcomb_str_gen_fun): DS.
* diff.c (dbg_clear, dbg_set, dbg_restore): DS.
* eval.c (do_eval, gather_free_refs, maprodv, maprendv,
maprodo, do_args_apf, do_args_ipf): DS.
(op_dwim, me_op, map_common): PS.
(prod_common): TS.
* ffi.c (struct txr_ffi_type): release member TS.
(make_ffi_type_pointer): PS and release argument TS.
(ffi_varray_dynsize, ffi_array_in, ffi_array_put_common,
ffi_array_get_common, ffi_varray_in, ffi_varray_null_term): PS.
(ffi_simple_release, ffi_ptr_in_release, ffi_struct_release,
ffi_wchar_array_get, ffi_array_release_common,
ffi_array_release, ffi_varray_release): TS.
(ffi_float_put, double_put, ffi_be_i16_put, ffi_be_u16_put,
ffi_le_i16_put, ffi_le_u16_put, ffi_be_i32_put, ffi_be_u32_put,
ffi_le_i32_put, ffi_sbit_put, ffi_ubit_put, ffi_buf_d_put,
make_ffi_type_array, make_ffi_type_enum, ffi_type_compile,
make_ffi_type_desc, ffi_make_call_desc, ffi_call_wrap,
ffi_closure_dispatch_save, ffi_put_into, ffi_in, ffi_get,
ffi_put, carray_set_length, carray_blank, carray_buf,
carray_buf_sync, carray_cptr, carray_refset, carray_sub,
carray_replace, carray_uint, carray_int): PS.
(carray_vec, carray_list): DS.
* filter.c (url_encode, url_decode, base64_stream_enc_impl): DS.
* ftw.c (ftw_callback, ftw_wrap): DS.
* gc.c (mark_obj, gc_set_delta): DS.
* glob.c (glob_wrap): DS.
* hash.c (equal_hash, eql_hash, eq_hash, do_make_hash,
hash_equal, set_hash_traversal_limit, gen_hash_seed): DS.
* itypes.c (c_i8, c_u8, c_i16, c_u16, c_i32, c_u32, c_i64,
c_u64, c_short, c_ushort, c_int, c_uint, c_long, c_ulong): PS.
* lib.c (seq_iter_rewind): TS and becomes internal.
(seq_iter_init_with_info, seq_setpos, replace_str, less,
replace_vec, diff, isec, obj_print_impl): PS.
(nthcdr, equal, mkstring, mkustring, upcase_str, downcase_str,
search_str, sub_str, cat_str, scat2, scat3, fmt_join,
split_str_keep, split_str_set, trim_str, int_str, chr_int,
chr_str, chr_str_set, vector, vecref, vecref_l, list_vec,
copy_vec, sub_vec, cat_vec, lazy_str_put, lazy_str_gt,
length_str_ge, length_str_lt, length_str_le, cptr_size_hint,
cptr_int, out_lazy_str, out_quasi_str, time_string_local_time,
time_string_utc, time_fields_local_time, time_fields_utc,
time_struct_local, time_struct_utc, make_time, time_meth,
time_parse_meth): DS.
(init_str, cat_str_init, cat_str_measure, cat_str_append,
vscat, time_fields_to_tm, time_struct_to_tm, make_time_impl): TS.
* lib.h (seq_iter_rewind): Declaration removed.
(c_num, c_unum, init_str): Declarations updated.
* match.c (LOG_MISMATCH, LOG_MATCH): PS.
(h_skip, h_coll, do_output_line, do_output, v_skip, v_fuzz,
v_collect): DS.
* parser.c (parser, circ_backpatch, report_security_problem,
hist_save, repl, lino_fileno, lino_getch, lineno_getl,
lineno_gets, lineno_open): DS.
(parser_set_lineno, lisp_parse_impl): PS.
* parser.l (YY_INPUT): PS.
* rand.c (make_random_state): PS.
* regex.c (print_rec): DS.
(search_regex): PS.
* signal.c (kill_wrap, raise_wrap, get_sig_handler,
getitimer_wrap, setitimer_wrap): DS.
* socket.c (addrinfo_in, sockaddr_pack, fd_timeout,
to_connect, open_sockfd, sock_mark_connected,
sock_timeout): TS.
(getaddrinfo_wrap, dgram_set_sock_peer, sock_bind,
sock_connect, sock_listen, sock_accept, sock_shutdown,
sock_send_timeout, sock_recv_timeout, socketpair_wrap): DS.
* stream.c (generic_fill_buf, errno_to_string, stdio_truncate,
string_out_put_string, open_fileno, open_command, base_name,
dir-name): DS.
(unget_byte, put_buf, fill_buf, fill_buf_adjust,
get_line_as_buf, formatv, put_byte, test_set_indent_mode,
test_neq_set_indent_mode, set_indent_mode, set_indent,
inc_indent, set_max_length, set_max_depth, open_subprocess, run ): PS.
(fds_subst, fds_swizzle): TS.
* struct.c (make_struct_type, super, umethod_args_fun): PS.
(method_args_fun): DS.
* strudel.c (strudel_put_buf, strudel_fill_buf): DS.
* sysif.c (errno_wrap, exit_wrap, usleep_wrap, mkdir_wrap,
ensure_dir, makedev_wrap, minor_wrap, major_wrap, mknod_wrap,
mkfifo_wrap, wait_wrap, wifexited, wexitstatus, wifsignaled,
wtermsig, wcoredump, wifstopped, wstopsig, wifcontinued,
dup_wrap, close_wrap, exit_star_wrap, umask_wrap, setuid_wrap,
seteuid_wrap, setgid_wrap, setegid_wrap,
simulate_setuid_setgid, getpwuid_wrap, fnmatch_wrap,
dlopen_wrap): DS.
(chmod_wrap, do_chown, flock_pack, do_utimes, poll_wrap,
setgroups_wrap, setresuid_wrap, setresgid_wrap, getgrgid_wrap): PS.
(c_time): TS.
* sysif.h (c_time): Declaration updated.
* syslog.c (openlog_wrap, syslog_wrap): DS.
* termios.c (termios_pack): TS.
(tcgetattr_wrap, tcsetattr_wrap, tcsendbreak_wrap,
tcdrain_wrap, tcflush_wrap, tcflow_rap, encode_speeds,
decode_speeds): DS.
* txr.c (compato, array_dim, gc_delta): DS.
* unwind.c (uw_find_frames_by_mask): DS.
* vm.c (vm_make_desc): PS.
(vm_make_closure, vm_swtch): DS.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Commit c9cab7138636c6c1d6e47f8d1a4053bec2dd0ad4, on Feb 1,
2019, breaks the following case:
@(define horiz)whatever@(end)
@(horiz)
The code assumes that if v_fun returned :decline, then the
function doesn't exist. That is false, because the function
may have a horizontal definition, as in the above example.
That's why in the original code, nothing was done in this case
to just allow the flow to proceed to the horizontal fallback,
where the call will be tried as a horizontal function.
The small problem with that was lack of a diagnosis when the
function actually doesn't exist (neither vertical nor
horizontal). In that case, the horizontal fallback will expect
a line of data. If no data arrives, then the undefined
function call is undiagnosed.
The idea behind c9cab7138636c6c1d6e47f8d1a4053bec2dd0ad4 was
to provide a diagnostic immediately. The right way to do that
is to check for a horizontal definition of the function. If
there isn't one, then error out, otherwise fall back on the
horizontal processing.
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* lisplib.c (each_prod_instantiate, each_prod_set_entries):
New static functions.
(lisplib_init): Register autoload of each-prod.tl via new
functions.
* share/txr/stdlib/each-prod.tl: New file.
* txr.1: Documented. Also, under the existing collect-each
family of operators, added the equivalence to mapping with
lambda to help clarify the semantics.
|
|
|
|
|
|
|
|
|
|
| |
maprodo is like maprod, but doesn't collect or return
anything. It's the Cartesian product analog of mapdo.
* eval.c (collect_nothing, maprodo): New static functions.
(eval_init): Register maprodo intrinsic.
* txr.1: Documented.
|
|
|
|
|
|
| |
* txr.1: In length and empty, don't refer to an "object"
parameter since the syntax calls it "iterable". Simplified
description of length.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
These functions convert any iterable to a list, vector or
string.
* eval.c (eval_init): Registered list-seq, vec-seq and str-seq
intrinsics.
* lib.c (list_seq, vec_seq, str_seq): New functions.
* lib.h (list_seq, vec_seq, str_seq): Declared.
* txr.1: Documented.
|
|
|
|
|
|
|
|
|
|
| |
* configure: detect strsignal, producing HAVE_STRSIGNAL symbol
in config.h.
* sysif.c (strsignal_wrap): New function.
(sysif_init): Register strsignal intrinsic.
* txr.1: Documented.
|
|
|
|
|
|
|
|
|
|
| |
* sysif.c (exit_wrap): Check for missing status argument, and
map to EXIT_SUCCESS.
(sysif_init): Register exit as having optional argument.
* txr.1: Update documentation regarding optional argument of
exit. Also, EXIT_SUCCESS and EXIT_FAILURE are no longer
mentioned, only that t maps to succes and nil to failure.
|
|
|
|
|
|
|
|
|
|
|
|
| |
* struct.c (static_slot_types): If a symbol is attached to an
empty type list in the static slot hash, then try triggering
auto-load on it. This function's result is relied on by the
struct macros for generating warnings; if we don't probe the
autload, we get spurious warnings about symbols not being the
name of any static slot.
(static_slot_type_reg): Copy and paste bug: store the type
into the correct, static slot type hash instead of the
instance slot type hash.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
All string_utf8(strerror(x)) calls are replaced with
errno_to_str(x).
* sysif.c (errno_to_str): New function.
(strerror_wrap): Now implemented via call to errno_to_str.
(mkdir_wrap, ensure_dir, chdir_wrap, getcwd_wrap, rmdir_wrap,
mknod_wrap, mkfifo_wrap, chmod_wrap, do_chown, symlink_wrap,
link_wrap, readlink_wrap, close_wrap, exec_wrap, stat_impl,
do_utimes, pipe_wrap, poll_wrap, getgroups_wrap, setuid_wrap,
seteuid_wrap, setgid_wrap, setegid_wrap, setgroups_wrap,
getresuid_wrap, getresgid_wrap, setresuid_wrap,
setresgid_wrap, crypt_wrap, uname_wrap): Use errno_to_str.
* sysif.h (errno_to_str): Declared.
* ftw.c (ftw_wrap): Use errno_to_str.
* socket.c (dgram_get_byte_callback, dgram_flush, sock_bind,
open_sockfd, sock_connect, sock_listen, sock_accept,
sock_shutdown, sock_timeout, socketpair_wrap): Likewise.
* stream.c (errno_to_string): Likewise, and don't handle
zero case any more; pass down to errno_to_str.
(stdio_close, pipe_close open_directory, open_file,
open_fileno, open_tail, fds_subst, open_command,
open_subprocess, run, remove_path, rename_path): Use
errno_to_str.
* termios.c (tcgetattr_wrap, tcsetattr_wrap, tcsetattr_wrap,
tcsendbreak_wrap, tcdrain_wrap, tcflush_wrap, tcflow_wrap):
Likewise.
diff --git a/termios.c b/termios.c
|
|
|
|
|
|
|
|
|
|
|
|
| |
* configure (have_strerror_r): New variable.
Detect whether we have strerror_r and which flavor:
GNU or POSIX. Define HAVE_STRERROR_GNU or HAVE_STRERROR_POSIX
in config.h.
* sysif.c (strerror_wrap): New function.
(sysif_init): Register strerror intrinsic.
* txr.1: Documented.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Curiously, the itypes_little_endian variable was introduced in
April 2017, in a the first commit implementing buffers. The
variable was initialized, but never referenced. About a month
after that, I introduced HAVE_LITTLE_ENDIAN config.h macro,
which is always present and defined as 0 or 1. This was used
right away in the implementation of FFI bitfields, and later
on in other FFI work. In spite of HAVE_LITTLE_ENDIAN, almost
exactly a year after itypes_little_endian was introduced, I
mistakenly put that variable to use instead of recognizing it
as superfluous and removing it in favor of using
HAVE_LITTLE_ENDIAN. That is what I'm doing now.
* itypes.c (itypes_little_endian): Variable removed.
(itypes_init): Function removed, since its only job is to
initialize this variable.
* itypesl.h (itypes_little_endian, itypes_init): Declarations
removed.
* lib.c (init): Call to itypes_init removed.
* parser.c (read_file_common): Instead of
itypes_little_indian, use HAVE_LITTLE_ENDIAN, which
the configuration script always exists and is defined
as 0 or 1.
|
|
|
|
|
|
|
|
|
| |
* parser.c (repl): The listener wrongly complains that
.txr_history has bad permissions when it doesn't exist.
New users of TXR won't have a history file, so this looks
sloppy. Since we load the history file regardless of the
check, let's do the check in the case when the file has
successfully loaded.
|
|
|
|
|
|
|
| |
* jmp.S (jmp_save, jmp_restore): Defined for MIPS64.
* unwind.h (struct_jmp): Provide same definition for 32 and 64
by #ifdef-ing on just __mips__.
|
|
|
|
|
| |
* jmp.S: Add missing .set noreoder: now everything compiles
and tests pass.
|
|
|
|
|
|
| |
* jmp.S (jmp_save, jmp_restore): Implement for 32 bit MIPS.
* unwind.h (struct jmp): 32 bit MIPS definition added.
|
|
|
|
|
|
|
|
|
| |
* unwind.c (invoke_handler): Do not unconditionally bind
*package* and *package-alist*. Allocate the new dynamic
environment only if the current values of those variables are
different from the ones stored in the frame. This is the
excpected case since package and package list manipulations
are rare.
|
|
|
|
|
|
|
|
| |
* txr.1: Implementing new >< operator in the getm macro
syntax. >< foo x bar renders as <foo>x<bar> in the nroff-ed
man output; in HTML and PDF, foo and bar are italicized.
This is put to use in the Built-In Syntactic Places section to
correct the formatting of struct-obj.slot-name.
|
|
|
|
|
|
|
|
| |
* txr.1: Fix missing backslash on font changing directive in
the troff-oriented implementation of the <> operator.
This makes no difference to the output. The HTML output is
absolutely identical according to diff. Visual inspections of
the groff-generated PDF also reveal no difference.
|
|
|
|
|
| |
* txr.1: Fix "Buffers" and "The buf type" being at equal
section levels. Adjust the cptr type section to harmonize.
|
|
|
|
|
|
|
|
|
|
| |
* RELNOTES: Updated.
* configure, txr.1: Bumped version and date.
* share/txr/stdlib/ver.tl: Likewise.
* txr.vim, tl.vim: Regenerated.
|
|
|
|
|
|
| |
* txr.1: Fix instances in which the sequence argument of a
sequence manipulating function is called a list or object.
Also fix some unnecessary abbreviation of sequence to seq.
|
|
|
|
|
|
|
| |
* txr.1: Relocate description of nullify from bottom of
Sequence Manipulation to near the top, after the description
of empty. This is very similar to the recent relocation of
nullify in lib.c and lib.h.
|
|
|
|
|
|
|
| |
* txr.1: Move description of make-like from near the bottom of
the Sequence Manipulation section to close to the top, just
under the seqp description. Also, ref-sequence parameter is
renamed to object.
|
|
|
|
|
| |
* txr.1: Move description of copy function out of Sequence
Manipulation and into Object Equivalence.
|
|
|
|
|
|
| |
* txr.1: Move the descriptions of apply and iapply out of
Sequence Manipulation and into Functions, following the
description of the call function.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The (each ()) form should infinitely loop, and the compiled
version does. The interpreter crashes, when that is a
top-level form. The reason is that the underlying sys:each-op
operator uses an empty list of variable names as an indication
to use the bindings from the parent lexical environment.
And in that particular case, the let is also empty. The
whole thing looks like:
(let () (sys:each-op each nil))
If this is a top-level expression, then op_let receives a null
environment pointer. Since it has no bindings to add, it
doesn't extend the environment chain and passes a null
environment pointer down to op_each, which that tries to use,
because it's told to reach into it for bindings.
Let's use the t symbol for that instead, so then the above
would look like:
;; the t and only the t means "access parent env"
(let () (sys:each-op each t))
And then, let's also fix it so that t is never used in this
case when there are no vars:
;; no t, and so don't access parent env.
(let () (sys:each-op each nil))
* eval.c (op_each): Get the bindings from the parent
environment if vars is t, rather than when it's null.
(me_each): When the symbols are not being inserted into the
sys:each-op form, then insert t to indicate that, rather than
nil. If the source form specifies an empty list of bindings,
then insert nil, not t.
* share/txr/stdlib/compiler.tl (expand-each): Get the list of
variable names from the parent lexical environment when vars
is t, rather than when it's null.
|
|
|
|
|
|
|
| |
This fixes cases like (isec 0..10 5..15).
* lib.c (seq_iter_rewind): Handle the rewinding of
non-sequence iterators (ranges, characters, numbers).
|
|
|
|
|
| |
* txr.1: Nullify documentation updated and clarified, with
examples.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Issues: (nullify 1..1) doesn't return nil as it
should, and (empty 1) fails.
* lib.c (seq_info): Since we would like nullify to use
seq_info, seq_info cannot call nullify. Transplant the probing
of the nullify method out of nullify and into here.
(nullify): Obtain a seq_info_t on the object. If it's not a
sequence and is not range, then just return the object.
Otherwise obtain a seq_iter_t sequence and peek whether it has
a next item.
(empty): Similarly, obtain an iterator and peek.
Definition of empty is relocated to be next to nullify.
* lib.h: Relocate declaration of empty, also.
|
|
|
|
|
|
|
|
|
|
|
|
| |
The recent refactoring of the mapping functions to use
stack-allocated iterators has a bug. args_decl occurs inside a
loop. But args_decl uses alloca, which doesn't dispose of the
memory when the block scope terminates.
* eval.c (map_common, prod_common): Move the declaration of
args_fun outside of the loop, so that it is allocated just
once. The loop just stuffs fresh sets of values into the
arguments.
|
|
|
|
|
|
|
|
|
| |
* lib.c (transpose): Don't simply copy the input, but convert
it to a list with tolist. The transposev function relies on
mapcarv, and that function now doesn't simply pull out the
trailing object from the args. It processes the args as args,
and a non-list causes problems there, such as args_count
reporting the wrong value.
|
|
|
|
|
|
|
|
| |
* doc: Add paragraphs uder Sequence Manipulation discussing
support for sequences, iterables and hashes. Establish naming
cnovention for arguments: iterables are called iterable or
iter. Update descriptions of functions that work with
iterables.
|
|
|
|
|
|
| |
* txr.1: The init-forms in (each ...) must be suitable for
iter-init and that is now documented. A (range 1 10)
in the example is replaced with 1..11.
|
|
|
|
|
| |
* txr.1: New section added under TXR LISP to introduce the
new iteration concept.
|
|
|
|
|
| |
* txr.1: Add more detail about list handling, and cover
numbers and ranges.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* lib.h (seq_iter_t): Add some union members to ui and ul for
use with ranges. The purpose of this is to have separate
naming for the iteration variables for ranges.
* lib.c (seq_iter_get_range_cnum, seq_iter_peek_range_cnum,
seq_iter_get_range_chr, seq_iter_peek_range_chr,
seq_iter_get_range_bignum, seq_iter_peek_range_bignum): Use
new union member names for clarity.
(seq_iter_get_rev_range_cnum, seq_iter_peek_rev_range_cnum,
seq_iter_get_rev_range_chr, seq_iter_peek_rev_range_chr,
seq_iter_get_rev_range_bignum,
seq_iter_peek_rev_range_bignum): New static functions.
(seq_iter_with_init_info): Drop obj argument since the si
argument has the object. Add handling for empty and reversed
ranges. Also convert unbounded ranges like N..t and N..: to
just N, recursively. Use new union member names.
(seq_iter_init, seq_iter_init_with_rewind, iter_begin,
iter_reset): Follow elimination of argument in
seq_iter_init_with_info.
|
|
|
|
|
|
|
|
|
|
|
|
| |
* lib.c (seq_iter_init_with_info): Take new Boolean argument
indicating whether the iterator needs to support the rewind
operation. If this is false, and the object is a list, then we
clobber the object, in order to eliminate the GC root.
(seq_iter_init, iter_begin, iter_reset): Pass 0 for the new
Boolean parameter.
(seq_iter_init_with_rewind): New function.
(diff, isec): Use seq_iter_init_with_rewind to request an
iterator with rewind support for the second sequence.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* eval.c (map_common): Do not extract the arguments as a list.
Do not produce a list of iterator objects. Instead, allocate
an array of seq_iter_t objects on the stack using alloca, and
use these for walking the input lists in parallel. Do not cons
a list of the tuples coming from the lists, but rather store
the tuples into a struct args, also on the stack, and invoke
the function with that. Now, the only heap memory we allocate
is the resulting list being accumulated. In the case of mapdo,
no heap allocation takes place. However, if some of the inputs
are hashes, then hash iterators get allocated in seq_iter_init.
(mapcarv, mappendv, mapdov): Pass self argument to map_common,
needed for seq_iter_init.
|
|
|
|
|
|
| |
* eval.c (map_common): New static function.
(mapcarv, mappendv, mapdov): Now one-line wrappers
for map_common.
|
|
|
|
|
|
|
|
|
|
|
| |
The one list case of maprod reduces to mappend rather than
mapcar, so that [maprod identity '(1 2 3)] fails instead
of producing (1 2 3).
* eval.c (prod_common): Take pointer to mapping function to
use in one-list case, and use it.
(maprodv): Pass mapcarv to prod_common.
(maprendv): Pass mappendv to prod_common.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* eval.c (get_iter_f): Renamed to iter_from_binding_f.
(iter_begin_f, iter_more_f, iter_item_f, iter_step_f): New
global variables.
(op_each): Follow rename of get_iter_f.
(mapcarv, mappendv, lazy_mapcar_func, lazy_mapcar,
lazy_mapcarv_func, lazy_mapcarv, mapdov, prod_common):
Convert from car/cdr/null-test iteration to iter-begin.
(eval_init): gc-protect and initialize new variables.
* lib.c (mapcar_listout, mappend, mapdo): Convert to seq_iter
iteration. List argument renamed to seq.
(mapcar): List argument renamed to seq.
* lib.h: Declarations updated with renamed arguments.
|