summaryrefslogtreecommitdiffstats
path: root/txr.1
Commit message (Collapse)AuthorAgeFilesLines
...
* readdir: skip . and .. entriesKaz Kylheku2020-07-081-0/+9
| | | | | | | * sysif.c (readdir_wrap): If d_name is "." or ".." loop around and get another directory entry. * txr.1: Documented.
* doc: iter-more vs oop iterator.Kaz Kylheku2020-07-081-2/+14
| | | | | * txr.1: Document that iter-more returns t when an oop-iterator does not feature the iter-more method.
* Expose low-level opendir/readdir dir traversal.Kaz Kylheku2020-07-081-0/+140
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * stream.c (UTF_DECL_OPENDIR): Macro defined, to enable w_opendir declaration in utf8.h. (w_opendir): Static function removed. * sysif.c (UTF_DECL_OPENDIR): Macro defined. (dir_s): Symbol defined unconditionally now, regardless of HAVE_PWUID. (dirent_s): New symbol. (dirent_st): New static variable. (struct dir): New struct type. (opendir_free, opendir_mark opendir_wrap, readdir_wrap): New static functions. (opendir_ops): New static structure. (sysif_init): Intern dirent symbol. Create dirent structure type. Register opendir and readdir intrinsic functions. Register variables dt-blk, dt-chr, dt-dir, dt-fifo, dt-lnk, dt-reg, dt-sock and dt-unknown. * utf8.c (UTF8_DECL_OPENDIR): Macro defined. (w_opendir): Function moved here from stream.c, and turned external. * utf8.h (w_opendir): Declared, conditionally on UTF8_DECL_OPENDIR being defined, so that most modules that include utf8.h don't have to include <dirent.h>. * txr.1: Documented. diff --git a/sysif.c b/sysif.c
* list_seq: return lazy list, not eager.Kaz Kylheku2020-07-081-0/+4
| | | | | | | | | * lib.c (list_seq_func): New static function. (list_seq): Convert to lazy processing. The iterator is threaded through the lazy cons's car field, so we don't have to mutate the function's environment. * txr.1: Added note about list-seq producing a lazy list.
* txr: support @(if)/@(elif)/@(else) in @(output).Kaz Kylheku2020-07-071-2/+47
| | | | | | | | | | | | | | | | | | | This turns out to be way easier than I thought. * match.c (do_output_if): New static function. (do_output): Handle if via do_output_if. * parser.y (out_if_clause, out_elif_clauses_opt, out_else_clause_opt): New nonterminal symbols and grammar rules. (out_clause): Now produces out_if_clause. (not_a_clause): Remove ELIF and ELSE; these entries here cause conflicts now. Here, continue to recognize the Lisp if, which is distinguished by having at least two arguments. out_if_clause matches only a one-argument if, and a no-argumeent one that is diagnosed as erroneous. * txr.1: Documented.
* New: protocol for iteration with structs.Kaz Kylheku2020-07-071-1/+277
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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.
* doc: grammar under pos-ifKaz Kylheku2020-07-061-1/+1
| | | | * txr.1: article missing: "satisfies [the] predicate function".
* New function: iterable.Kaz Kylheku2020-07-021-0/+24
| | | | | | | | | | | | * 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.
* crc32: add optional initial crc argument.Kaz Kylheku2020-06-301-4/+34
| | | | | | | | | | | | | | 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.
* New producting each operator family.Kaz Kylheku2020-06-281-0/+172
| | | | | | | | | | | | | * 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.
* New function: maprodo.Kaz Kylheku2020-06-281-7/+21
| | | | | | | | | | 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.
* doc: parameter of length and empty is "iterable".Kaz Kylheku2020-06-281-43/+4
| | | | | | * txr.1: In length and empty, don't refer to an "object" parameter since the syntax calls it "iterable". Simplified description of length.
* New functions: list-seq, ved-seq and str-seq.Kaz Kylheku2020-06-281-0/+29
| | | | | | | | | | | | | | 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.
* New function strsignal.Kaz Kylheku2020-06-271-0/+10
| | | | | | | | | | * configure: detect strsignal, producing HAVE_STRSIGNAL symbol in config.h. * sysif.c (strsignal_wrap): New function. (sysif_init): Register strsignal intrinsic. * txr.1: Documented.
* exit: argument becomes optionalKaz Kylheku2020-06-201-11/+13
| | | | | | | | | | * 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.
* Replace all strerror calls with wrapper.Kaz Kylheku2020-06-201-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* New function: strerrorKaz Kylheku2020-06-191-0/+17
| | | | | | | | | | | | * 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.
* doc: new >< operator.Kaz Kylheku2020-06-101-5/+23
| | | | | | | | * 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.
* doc: missing backslash in getm macro.Kaz Kylheku2020-06-101-1/+1
| | | | | | | | * 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.
* doc: Buffers: subsectioning problem.Kaz Kylheku2020-06-091-3/+6
| | | | | * txr.1: Fix "Buffers" and "The buf type" being at equal section levels. Adjust the cptr type section to harmonize.
* Version 240txr-240Kaz Kylheku2020-06-061-3/+3
| | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise. * txr.vim, tl.vim: Regenerated.
* doc: fix param names in Sequence Manipulation.Kaz Kylheku2020-06-061-84/+93
| | | | | | * 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.
* doc: relocate nullify.Kaz Kylheku2020-06-061-99/+99
| | | | | | | * 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.
* doc: relocate make-like.Kaz Kylheku2020-06-061-57/+57
| | | | | | | * 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.
* doc: relocate copy.Kaz Kylheku2020-06-061-80/+80
| | | | | * txr.1: Move description of copy function out of Sequence Manipulation and into Object Equivalence.
* doc: relocate apply/iapply.Kaz Kylheku2020-06-061-146/+146
| | | | | | * txr.1: Move the descriptions of apply and iapply out of Sequence Manipulation and into Functions, following the description of the call function.
* doc: update nullify documentation.Kaz Kylheku2020-06-051-39/+71
| | | | | * txr.1: Nullify documentation updated and clarified, with examples.
* doc: document functions that take iterable.Kaz Kylheku2020-06-051-91/+138
| | | | | | | | * 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.
* doc: document each operators using iterables.Kaz Kylheku2020-06-051-8/+11
| | | | | | * 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.
* doc: new Generalization of Iteration section.Kaz Kylheku2020-06-051-0/+120
| | | | | * txr.1: New section added under TXR LISP to introduce the new iteration concept.
* doc: update iter-begin documentation.Kaz Kylheku2020-06-051-8/+168
| | | | | * txr.1: Add more detail about list handling, and cover numbers and ranges.
* New style iteration functions.Kaz Kylheku2020-06-021-5/+157
| | | | | | | | | | | | | | | | | | | | | | | | iter-begin provides a paradigm for iteration that is more compatible with lists. If the sequence is a list, then the list itself is returned as the iterator, and the other functions are basicaly wrappers for car/cdr and null testing. Yet the API is defined in such a way that other objects can be iterated with good efficiency, at the cost of allocating a new iterator object (which can be re-used). * eval.c (eval_init): Register iter-begin, iter-more, iter-item, iter-step and iter-reset. * lib.c (seq_iter_init_with_info): New static function. (seq_iter_init): Now a thin wrapper for seq_iter_init_with_info. (iter_begin, iter_more, iter_item, iter_step, iter_reset): New functions. * lib.h (iter_begin, iter_more, iter_item, iter_step, iter_reset): New functions. * txr.1: Documented.
* Version 239.txr-239Kaz Kylheku2020-06-021-2/+2
| | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise.
* doc: constantp syntax formatting.Kaz Kylheku2020-05-311-1/+1
| | | | * txr.1: Fix extra whitespace around env parameter.
* search, rsearch: rewrite using seq_info and bugfix.Kaz Kylheku2020-05-251-4/+16
| | | | | | | | | | | | | | | * lib.c (seq_getpos, seq_setpos): New functions. * lib.h (seq_getpos, seq_setpos): Declared. (search_list, rsearch_list): Static functions removed. (search_common): New static function. (search, contains, rsearch): These functions are now trivial wrappers around search_common. A requirement problem is fixed in rsearch: when the key is empty, the length of sequence is returned rather than zero, because zero is obviously not the right most place where an empty key matches. * txr.1: Documentation updated.
* Fix few typos reported from Fossies.Kaz Kylheku2020-05-231-2/+2
| | | | | | | | | | | | | Fossies administrator Jens alerted me to some typos. * txr.1: Fix two instances of alphanumeric being hyphenated, and one case of invocable being rendered as invokable. * linenoise/linenoise.c (struct lino_state): Misspelled "buffer" in a comment. One other comment typos in this file is from the original code, so it stays: who needs yet another merge conflict? Not touching the original typo in example.c, either.
* Version 238.txr-238Kaz Kylheku2020-05-181-3/+3
| | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise. * txr.vim, tl.vim: Regenerated.
* New assert macro.Kaz Kylheku2020-05-181-0/+35
| | | | | | | | | | | | * eval.c (rt_assert_fail, me_assert): New static functions. (eval_init): assert macro and sys:rt-assert-fail function registered. * lib.c (func_n4ov): New function. * lib.h (func_n4ov): Declared. * txr.1: Documented.
* sort: prudently make it subject to compat valueKaz Kylheku2020-05-141-0/+20
| | | | | | | | | | | | * eval.c (eval_init): If opt_compat is 237 or less, make sort and shuffle destructive. * share/txr/stdlib/getopts.tl (opthelp): Revert previous change, restoring use of copy-list and use nsort instead of sort, so the function is not affected by the 237 compatibility being turned on. * txr.1: Add compatibility notes.
* lib: sort becomes non-destructive; nsort introduced.Kaz Kylheku2020-05-131-8/+39
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | I'm fixing a historic mistake copied from ANSI Lisp, which trips up language newcomers and sometimes even experienced users. The function innocently named sort will now return newly allocated structure. The function previously called sort will be available as nsort (non-consing/allocating sort). The shuffle function also becomes pure, and is accompanied by nshuffle. * eval (me_op): Continue to use destructive sort in this legacy code that is only triggered in very old compat mode. (eval_init): Registered nsort and nshuffle. * lib.c (nsort, nshuffle): New functions introduced, closely based on sort and shuffle. (sort, shuffle): Rewritten to avoid destructive behavior: work by copying the input and calling destructive counterparts. (sort_group): Continue to use destructive sort, which is safe; the structure is locally allocated. The sort_group function has pure semantics. (grade): Likewise. * lib.h (nsort, nshuffle): Declared. * share/txr/stdlib/getopts.tl (opthelp): Replace an instance of the (sort (copy-list ...)) pattern with just (sort ...). * tags.tl (toplevel): Continue to use destructive sort to sort tags before writing the tag file; the lifetime of the tags list ends when the file is written. * tests/010/seq.txr: Switch some sort calls to nsort to keep test case working. * txr.1: Documented.
* lib: use seq-info for sort and shuffle.Kaz Kylheku2020-05-131-0/+20
| | | | | | | | * lib.c (sort, shuffle): Switch to seq_info. For consistency with sort, shuffle now handles hashes in the same peculiar way. * txr.1: Document hash behavior for sort and shuffle.
* Expose isatty function.Kaz Kylheku2020-05-111-0/+33
| | | | | | | * sysif.c (isatty_wrap): New function. (sysif_init): Register isatty intrinsic. * txr.1: Documented.
* doc: quote, umethod, hash-invert: bad syntaxKaz Kylheku2020-05-091-3/+3
| | | | | * txr.1: Remove manually added angle brackets on <form>. Fix inappropriate use of << and >>.
* symbol-function: bugfix: expand lambda expression.Kaz Kylheku2020-05-031-1/+2
| | | | | | | * eval.c (lookup_fun): A lambda expression must be expanded before being turned into a function. * txr.1: Documented.
* compiler: honor load-time in parts of loop.Kaz Kylheku2020-05-031-0/+14
| | | | | | | | | | | | | | | | * share/txr/stdlib/compiler.tl (compiler comp-for): If a for loop occurs in the top level, or inside a load-time, then we don't want to suppress the semantics of load-time for any parts of the loop that are repeatedly evaluated. The programmer may be doing that specifically to hoist those calculations out of the loop. We thus bind *load-time* to nil after compiling the initializing and test expressions. * txr.1: New paragraph in Notes for load-time, mentioning compiler treatment of loops and lambda. The language is deliberately general rather than being specifically about the for loop, because several loop constructs compile to the for loop, and that is also subject to future changes.
* compiler: treat nested load-time forms.Kaz Kylheku2020-05-021-0/+46
| | | | | | | | | | | | | | | | | | | | | | | load-time forms nested in load-time forms have no special semantics; it's wasteful to separately hoist them into load time and store their value in their own D register. We must be careful: this is not true if a nested form occurs in a lambda. * share/txr/stdlib/compiler.tl (*load-time*): New special variable. (compiler comp-lambda): Bind *load-time* to nil around the compilation of the lambda, so load-time forms in the lambda are hoisted to load time, even if the lambda itself is wrapped in a load-time form. (compiler comp-load-time-lit): Bind *load-time* true around the compilation of the form. If *load-time* is already true, then skip the special load-time logic and just compile the enclosed form; the surrounding load-time compilation is taking care of the load-time hoisting. * txr.1: Document that load-time forms nested in load-time forms don't do anything, except in the lambda case.
* doc: new typos under User-Defined Streams.Kaz Kylheku2020-05-021-4/+4
| | | | | * txr.1: Fix typos and incorrect symbol under put-buf and fill-buf method.
* doc: mention zero-width bit-field at end of structure.Kaz Kylheku2020-04-271-1/+2
| | | | | * txr.1: A zero-width bit-field placed as the last member can have an effect on the structure; let's mention it.
* doc: fix wrong claim in Bitfield Allocation Rules.Kaz Kylheku2020-04-271-9/+6
| | | | | | | | * txr.1: Rewriting the last two sentences to fix the wrong claim of its last two sentences, which contradicts the correct statement in the the previous paragraph. The statements are only correct about big-endian, not about both types of machine.
* Version 237.txr-237Kaz Kylheku2020-04-261-3/+3
| | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise. * txr.vim, tl.vim: Regenerated.