summaryrefslogtreecommitdiffstats
path: root/txr.1
Commit message (Collapse)AuthorAgeFilesLines
* 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.
* buf: new buffer stream.Kaz Kylheku2017-08-141-0/+120
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * buf.c (struct buf_strm): New struct type. (buf_strm_mark, int buf_strm_put_byte_callback, buf_strm_put_string, buf_strm_put_char, buf_strm_put_byte, buf_strm_get_byte_callback, buf_strm_get_char, buf_strm_get_byte, buf_strm_unget_char, buf_strm_unget_byte, buf_strm_seek, buf_strm_truncate, buf_strm_get_prop, buf_strm_set_prop, buf_strm_get_error, buf_strm_get_error_str): New static functions. (buf_strm_ops): New static struct. (buf_strm): New static function. (make_buf_stream, get_buf_from_stream): New functions. (buf_init): Register new intrinsic functiions make-buf-stream and get-buf-from-stream. Call fill_stream_ops on new buf_strm_ops to fill default operations in place of function pointers that have been left null. * buf.h (make_buf_stream, get_buf_from_stream): Declared. * lisplib.c (with_stream_set_entries): Add with-out-buf-stream and with-in-buf-stream to auto-load symbols for with-stream.tl module. * share/txr/stdlib/with-stream.tl (with-out-buf-stream, with-in-buf-stream): New macros. * txr.1: New section about buffer streams.
* ffi: new buf-carray function.Kaz Kylheku2017-08-081-0/+18
| | | | | | | | | * ffi.c (buf_carray): New function. (ffi_init): Registered buf-carray intrinsic. * ffi.c (buf_carray): Declared. * txr.1: Documented.
* New divides function.Kaz Kylheku2017-08-071-0/+29
| | | | | | | | | * arith.c (divides): New function. (arith_init): Intrinsic registered. * arith.h (divides): Declared. * txr.1: Documented.
* Make len a synonym for length.Kaz Kylheku2017-08-071-1/+7
| | | | | | | * eval.c (eval_init): Register the same function under length and len. * txr.1: Documented.
* New spl and tok: variants of tok-str and split-str.Kaz Kylheku2017-08-071-0/+68
| | | | | | | | * eval.c (eval_init): Register spl and tok intrinsics. * lib.c (spl, tok): New functions. * txr.1: Documented.
* Add sum and prod convenience functions.Kaz Kylheku2017-08-051-0/+44
| | | | | | | | | | * eval.c (eval_init): prod and sum intrinsics registered. * lib.c (sum, prod): New functions. * lib.h (sum, prod): Declared. * txr.1: Documented.
* New functions digpow and digits.Kaz Kylheku2017-08-051-0/+90
| | | | | | | | | | | * arith.c (digcommon): New static function. (digpow, digits): New functions. (arith_init): New digpow and digits intrinsic functions registered. * arith.h (digpow, digits): Declared. * txr.1: New functions documented.
* Bi-directional string tree match for non-vars.Kaz Kylheku2017-08-021-0/+28
| | | | | | | | | | | | | | | | | | There is an inconsistency in @(bind) in that given @(bind x y) where x is a variable, both directions are tried for a string tree match. x could be tree of strings and y a string atom, or vice versa. But if x is just an atom, or a Lisp evaluation, then only one direction is tried. @(bind @(list "a" "b") "a") succeeds, but @(bind "a" @(list "a" "b")) fails. * match.c (dest_bind): Test both directions in the scalar and Lisp evaluated cases of the left hand side. Subject to compatibility, just in case. * txr.1: Compat note added.
* doc: aret description refers to ret.Kaz Kylheku2017-08-021-1/+1
| | | | | * txr.1: Fix description of aret, which wrongly refers to the ret macro.
* doc: explain qref and uref.Kaz Kylheku2017-08-021-6/+17
| | | | | * txr.1: Under the qref and uref operators, mention what these stand for and how the terminology is derived.
* doc: note about global symbol macros.Kaz Kylheku2017-08-021-0/+4
| | | | | * txr.1: Adding note that a symbol cannot be a global symbol macro and global variable at the same time.
* doc: missing formatting in qref equivalence.Kaz Kylheku2017-08-021-0/+2
| | | | | * txr.1: equivalence between .(qref ...) and (uref ...) now typeset properly in monospaced font.
* doc: mention listener in Lisp intro.Kaz Kylheku2017-08-021-4/+6
| | | | | | * txr.1: Remove clumsy "firstly, secondly, thirdly" because we need a "fourthly" which is too much. Intro now mentions that Lisp evaluation is also possible via the listener.