summaryrefslogtreecommitdiffstats
path: root/txr.1
Commit message (Collapse)AuthorAgeFilesLines
...
* doc: wrong typesetting of suspend.Kaz Kylheku2017-12-141-1/+1
| | | | | | * txr.1: Example for sys:capture-cond uses wrong style for the reference to the suspend operator suspend, causing it not to be hyper-linked to the definition in the HTML version.
* doc: swapped words in continuations description.Kaz Kylheku2017-12-141-1/+1
| | | | | | * txr.1: Paragraph about sys:cont-poison must say "continuation's evaluation frames" not "evaluation's continuation frames"
* doc: attempt to clarify continuations.Kaz Kylheku2017-12-141-18/+85
| | | | | | | * txr.1: Under sys:capture cont, try to revise some potentially confusing text. Also adding more notes, clarifying the semantics of shared lexical environments, and behavior of special variable bindings with regard to continuations.
* doc: example formatting under tuples.Kaz Kylheku2017-12-141-1/+2
| | | | | | * txr.1: Fix example code that is too wide, causing a visual problem for standard 80 column man page formatting.
* doc: severe formatting problem under int-str.Kaz Kylheku2017-12-141-2/+2
| | | | | * txr.1: Fix lack of escaping of backslash in #\c causing the c to be interpreted as a troff code.
* doc: mapcar heading problem.Kaz Kylheku2017-12-141-1/+1
| | | | * txr.1: Add missing comma in mapcar section heading.
* Structure delegate streams documented.Kaz Kylheku2017-12-141-0/+446
| | | | | | | * txr.1: New major (SS*) section User-Defined Streams. Documented make-struct-delegate-stream function, the stream-wrap class and all the stream interface object methods.
* hash tables: now default to :equal-based.Kaz Kylheku2017-12-061-35/+85
| | | | | | | | | | | | | | * hash.c (eql_based_k): New keyword variable. (equal_based_p): New static function. (hashv): Use eql_based_p to determine whether to make an equal-based hash table. Subject to opt_compat relative to version 187. (hash_init): Intern :eql-based keyword and store in new variable. * hash.h (eql_based_k, userdata_k): Declared. * txr.1: Documentation updated, with compat notes too.
* macros: expand declined form in outer env.Kaz Kylheku2017-11-241-1/+37
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* New function: grade.Kaz Kylheku2017-11-231-0/+45
| | | | | | | | | | | | Inspired by APL. * eval.c (eval_init): Register grade intrinsic. * lib.c (grade): New function. * lib.h (grade): Declared. * txr.1: Documented.
* doc: re-doc append, split off append*.Kaz Kylheku2017-11-221-26/+134
| | | | | | | * 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.
* Version 187.txr-187Kaz Kylheku2017-11-171-2/+2
| | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise. * txr.vim: Regenerated.
* doc: pos-max, find-max: notes about multiple maxima.Kaz Kylheku2017-11-161-0/+25
| | | | | | * 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).
* rfind-if: optimized rewrite and hash support.Kaz Kylheku2017-11-151-1/+13
| | | | | | | | | | * 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.
* find-if: optimized rewrite and hash support.Kaz Kylheku2017-11-151-1/+15
| | | | | | | | | | * 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.
* doc: subtypep unspecified behaviorKaz Kylheku2017-11-141-0/+3
| | | | | * txr.1: Behavior of subtypep is not specified if either argument isn't a type.
* doc: wording under eq.Kaz Kylheku2017-10-301-1/+1
| | | | | * txr.1: fix awkward wording which applies the definite article "the" to a Lisp expression.
* doc: wrong wording under put-buf.Kaz Kylheku2017-10-301-1/+1
| | | | * txr.1: Streams support put-byte, not buffers.
* awk: implement ranges right using functions.Kaz Kylheku2017-10-291-8/+9
| | | | | | | | | | | | | | | | | | | | * 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.
* New convenience I/O functions for buffers.Kaz Kylheku2017-10-271-0/+67
| | | | | | | | | | | | | * 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.
* doc: grammar in description of rr.Kaz Kylheku2017-10-261-1/+1
| | | | * txr.1: rr searches for "a match" not "a matches".
* doc: partition function: syntax formattingKaz Kylheku2017-10-261-1/+1
| | | | | | * txr.1: Fix bungled formatting of third argument alternatives in the syntax synopsis of the partition function.
* awk: five new range operators.Kaz Kylheku2017-10-251-47/+195
| | | | | | | | | | | | * 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.
* New variant of op: lop.Kaz Kylheku2017-10-191-0/+90
| | | | | | | | | | * 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.
* Fixes in partition, partition*, split and split*.Kaz Kylheku2017-09-291-74/+85
| | | | | | | | | | | | | | | | | | | | | | | | | | Bunch of issues here: broken pre-171 compatibility, non-termination on lazy infinite lists of indices, doc issues. * lib.c (partition_func, split_func, split_star_func): Do the check for negative index values here, with the compat handling for 170 or older. (partition_split_common): Remove code that tries to adjust negative indices, and delete zeros or indices that are still negative after adjustment. The code consumes the entire list of prefixes, so chokes on lazy lists. Also in the compat case, there is complete breakage: the loop doesn't execute, and so out is just nil, and it is taken as the index list. (partition_star_func): Similar change like in partition_func. (partition_star): Similarly to partition_split_common, take out the bogus loop. Also take out loop that tries to remove leading negatives: we cannot do that because we haven't normalized them. * txr.1: Revised doc. Condensed by describing index-list argument in detail under partition. For the other functions, we refer to that one. Conditions for safely handling infinite list of indices spelled out.
* Version 186.txr-186Kaz Kylheku2017-09-161-2/+2
| | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise. * txr.vim, tl.vim: Regenerated.
* doc: issues in qquote example.Kaz Kylheku2017-09-141-2/+2
| | | | | * txr.1: fix flaw in comment next to ^(qquote (unquote ,x)). Clarify accompanying text.
* doc: improve example under regsubKaz Kylheku2017-09-141-1/+1
| | | | * txr.1: instead of (op r^ ...) we can use (fr^ ...).
* doc: grammar under make-zstruct.Kaz Kylheku2017-09-141-1/+1
| | | | * txr.1: singularize inappropriate plural.
* doc: move away from "text processing".Kaz Kylheku2017-09-141-7/+6
| | | | | | * txr.1: Change title and heading to just "programming language". Opening paragraph explains TXR as being a programming language supporting multiple paradigms.
* doc: mention FFI early.Kaz Kylheku2017-09-141-0/+3
| | | | * txr.1: Introductory paragraphs mention FFI.
* doc: more notes on regex % operator syntax.Kaz Kylheku2017-09-121-0/+34
| | | | | | * txr.1: The dual precedence of % leads to surprises; when parentheses are used around % expressions, they don't behave symmetrically on both sides.
* regex: new function, regex-prefix-match.Kaz Kylheku2017-09-111-0/+69
| | | | | | | | | | | | | | | | | This new function allows a program to determine whether a given string is the prefix of any of the strings denoted by a regular expression; or, in alternative words, whether a given string is the prefix of a possibly longer string which matches a regular expression. * regex.c (regex_machine_infer_init_state): New static function. (regex_prefix_match): New function. (regex_init): regex-prefix-match intrinsic registered. regex.h (regex_prefix_match): Declared. * txr.1: Documented.
* parser: fix precedence of DOTDOT.Kaz Kylheku2017-09-071-0/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | The problem is that a.b .. c.d parses as (qref a b..c d), which is useless and counterintuitive. Let's fix it, but with a backward compatibility switch to give more leeway to any hapless people out there whose code happens to depend on this unfortunate situation. We basically use two token numbers for the .. token: OLD_DOTDOT, and DOTDOT. Both are wired into the grammar. In backward compatibility mode, the lexer pumps out OLD_DOTDOT. Otherwise DOTDOT. * parser.l (grammar): When .. is scanned, return OLD_DOTDOT when in compatibility with 185 or earlier. Otherwise DOTDOT. * parser.y (OLD_DOTDOT): New terminal symbol; introduced at the same high precedence previously occupied by DOTDOT. (DOTDOT): Changes precedence to lower than '.' and UREFDOT. (n_expr): Two productions added involving OLD_DOTDOT. These are copy and paste of the existing productions involving DOTDOT; the only difference is that OLD_DOTDOT replaces DOTDOT. (yybadtoken): Handle OLD_DOTDOT. * txr.1: Compat notes added.
* New functions for polynomial evaluation.Kaz Kylheku2017-09-051-0/+66
| | | | | | | | | * arith.c (poly, rpoly): New functions. (arith_init): Registered intrinsics poly and rpoly. * arith.h (poly, rpoly): Declared. * txr.1: Documented.
* new: macroexpand-lisp1 and macroexpand-1-lisp1.Kaz Kylheku2017-08-311-0/+39
| | | | | | | | | | | | | | | | * eval.c (do_macroexpand_1, do_macroexpand): New static functions; take symbol macro lookup function poiner as argument. (macroexpand_1): Reimplemented as wrapper around do_macroexpand_1. (macroexpand): Reimplemented as wrapper around do_macroexpand. (macroexpand_1_lisp1, macroexpand_lisp1): New static functions. (eval_init): Registered intrinsics macroexpand-1-lisp1 and macroexpand-lisp1. * txr.1: Documented.
* New function: inverse of cumulative normal dist.Kaz Kylheku2017-08-311-0/+19
| | | | | | | | | | * arith.c (inv_cum_norm): New function. * arith.h (inv_cum_norm): Declared. * eval.c (eval_init): Register inv-cum-norm intrinsic. * txr.1: Documented.
* Version 185.txr-185Kaz Kylheku2017-08-301-2/+2
| | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise. * txr.vim, tl.vim: Regenerated.
* doc: wrong symbol under unique function.Kaz Kylheku2017-08-291-1/+1
| | | | | * txr.1: Fix syntax synopsis for unique identifying the function as uniq.
* doc: formatting under expand-leftKaz Kylheku2017-08-291-1/+1
| | | | * txr.1: Fix run-on period included in .meta formatting.
* Rewriting op/do macros in Lisp.Kaz Kylheku2017-08-291-25/+32
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The new implementation treats the @1, @2 ... @rest op arguments as local macros, leveraging the power of the macro expander to perform the substitution which renames these to gensyms. As a result, the implementation is correct. The old implementation blindly walks the tree structure doing the substitution, so that @1 is substituted even though it is in a quoted literal: [(op list '(@1)) 42] -> ((#:arg-01-0166)) under the new implementation, '(@1) is left alone: [(op list '(@1)) 42] -> ((@1) 42) * eval.c (expand_quasi): Because the new op macro doesn't rudely reach into quasi forms to substitute sys:var elements, relying on macro expansion, we must now macro-expand sys:var elements. The sys:var macro created by op is smart enough to skip the compound ones that have modifiers; they are handled via the inner expansion of the symbol. That is to say, `@@1` contains the structure (sys:var (sys:var 1)). The sys:var macro ignores the outer sys:var. But existing behavior in expand_quasi expands the inner (sys:var 1), so the substitution takes place. (eval_init): Do not register the hacky old op and do macros, except in compatibility mode with 184 or older. * lisplib.c (op_set_entries, op_instantiate): New functions. (dlt_register): Register auto-loads for op and do macros via new functions, except when in compatibility mode with 184 or older, in which case we want the old build-in hacky op to be used. * share/txr/stdlib/op.tl: New file. * txr.1: Fixed or removed no-longer-true text which hints at special hacks implemented in the op expander. Added compatibility notes for all new compat-switched op behaviors.
* doc: remove wrong/outdated claim under op macro.Kaz Kylheku2017-08-291-12/+1
| | | | | | * txr.1: the quasiliteral `rest: @rest` and `rest: @@rest` in fact produce the same result. Remove text which claims that the second one is erroneous.
* expander: do dot-to-apply for meta-expressions.Kaz Kylheku2017-08-281-5/+30
| | | | | | | | | | | | | | | | | | | The dot-to-apply transformation is now applied when meta-expressions like @foo and @(bar) apparently occur in the dot position. This change is made in anticipation of a rewrite of the op macro, in which the @1, @2, and @rest arguments will be implemented as macrolets, rather than the ad-hoc, hacky code walk currently performed in the transform_op function. * eval.c (dot_meta_list_p): New static function. (dot_to_apply): Detect the presence of a sys:var or sys:expr argument in a form. If found, then turn it and the remaining forms into a single compound form which replaces them. * txr.1: Update doc under Dot Position in Function Calls.
* Version 184.txr-184Kaz Kylheku2017-08-231-2/+2
| | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise. * txr.vim, tl.vim, protsym.c: Regenerated.
* Change return value spec for base64 stream functions.Kaz Kylheku2017-08-221-6/+4
| | | | | | | | | * filter.c (base64_stream_enc, base64_stream_dec): Count bytes encoded or decoded (using a fast integral counter which efficiently overflows to a Lisp value that may be a bignum). * txr.1: Doc updated.
* Default the length argument of truncate-stream.Kaz Kylheku2017-08-211-1/+16
| | | | | | | | | | * stream.c (truncate_stream): If the len argument is missing, default to the current position, obtained by using the seek operation. (stream_init): Fix up registration of truncate-stream for one optional argument. * txr.1: Documentation of truncate-stream updated.
* Update and expose base64 stream functions.Kaz Kylheku2017-08-181-6/+88
| | | | | | | | | | | | | | | | | | | * filter.c (base64_stream_enc): Change return value behavior. Return in unlimited mode, or number of bytes encoded. (get_base64_char): Stop reading when an invalid character is encountered, push it back and and return 0. (b64_code): Don't throw for invalid characters. This case now only occurs if 0 is passed in. (base64_stream_dec): Drop nchars argument. Read until get_base64_char returns 0 due to EOF or an invalid character. (base64_decode): Don't pass third arg to base64_stream_dec. (filter_init): base64-stream-enc and base64-stream-dec intrinsics registered. * filter.h (base64_stream_dec): Declaration updated. * txr.1: Documented.
* Revising out-of-memory handling.Kaz Kylheku2017-08-181-0/+2
| | | | | | | | | | | | | | | | | | | | | We don't want to be aborting on OOM, but throwing an exception. * lib.c (alloc_error_s): New symbol variable. (oom_realloc): Global variable removed. (oom): New static function. (chk_malloc, chk_malloc_gc_more, chk_calloc, chk_realloc): Call oom instead of removed oom_realloc handler. (env): Throw alloc-error rather than error by calling oom. (obj_init): Initialize alloc_error_s. (init): Drop function pointer argument; do not initialize removed oom_realloc. * lib.h (alloc_error_s): Declared. (oom_realloc): Declaration removed. (init): Declaration updated. * txr.1: Type tree diagram includes alloc-error.
* Allow character inputs in some bit operations.Kaz Kylheku2017-08-161-1/+15
| | | | | | | | | * arith.c (logand, logior, logxor): Allow one operand to be a character, if the opposite opernad is a fixnum integer. The result is a character. (bit): Allow the value being tested to be a character. * txr.1: Updated.
* ffi: new FFI type I/O functions.Kaz Kylheku2017-08-161-0/+91
| | | | | | | | | * ffi.c (put_obj, get_obj, fill_obj): New functions. (ffi_init): put-obj, get-obj, fill-obj intrinsics registered. * ffi.h (put_obj, get_obj, fill_obj): Declared. * txr.1: Documented.