summaryrefslogtreecommitdiffstats
path: root/txr.1
Commit message (Collapse)AuthorAgeFilesLines
...
* doc: cptr-put does not exist.Kaz Kylheku2021-07-021-5/+5
| | | | | | | | | | | * txr.1: There is no cptr-put function; it is called cptr-out. The last paragraph refers to cptr-out and it is referenced elsewhere. It has to be cptr-out because it implements the "out semantics" in FFI conversion which pairs with "put"; cptr-put would be a different function, which is not currently implemented. * stdlib/doc-syms.tl: Updated.
* doc: fix various issues in .coNP lines.Paul A. Patience2021-07-011-11/+11
| | | | | | | | | | | * txr.1: Make consistent the style for ellipses in .coNP lines (i.e., without the word "and"). Emend some incorrectly named symbols. Fix various typos and other inconsistencies in .coNP lines. * checkman.txr (check-func): Add exception for caar. Add missing patterns for "Pattern macro", "Operator/function" and "Macro/function". * stdlib/doc-syms.tl: Updated.
* doc: include opt-error in diagram.Kaz Kylheku2021-06-301-0/+2
| | | | * txr.1: Exception hierarchy diagram now includes opt-error.
* path-cat: becomes variadic.Kaz Kylheku2021-06-291-7/+51
| | | | | | | | | | | | | * stream.c (path_vcat): New static function. (stream_init): Register path-cat instrinsic to path_vcat rather than path_cat. * tests/018/path.tl: path-cat tests: all examples from documentation, plus others. * txr.1: Documented existing behaviors that were not clear, like when inputs are empty. Documented new variadic semantics. Examples added.
* doc: mistake in several path-cat examples.Kaz Kylheku2021-06-291-3/+3
| | | | | * txr.1: Corrections to three examples, where one operand is empty, and thus the other is returned.
* doc-lookup: use BROWSER variable; provide fallback.Kaz Kylheku2021-06-291-2/+27
| | | | | | | | | * stdlib/doc-lookup.tl (open-url): On non-Windows platforms, search for a program specified by the BROWSER variable, then by the URL-opening utility, and finally thorugh a fallback list of browsers. * txr.1: Documentation updated.
* New function: find-true.Kaz Kylheku2021-06-291-1/+18
| | | | | | | | | | | | | | | This is like find-if, but returns the value of the predicate function rather than the item. * eval.c (eval_init): Register find-true instrinsic. * lib.c (find_true): New function. * lib.c (find_true): Declared. * stdlib/doc-syms.tl: Updated. * txr.1: Documented.
* New function: path-search.Kaz Kylheku2021-06-291-0/+73
| | | | | | | | | | | | * lisplib.c (path_test_set_entries): Autoload on path-search. * stdlib/path-test.tl (path-search): New function. * tests/018/path-test.tl: New file. * txr.1: Documented. * stdlib/doc-lookup.tl: Updated.
* constantp: fully expand; recognize functions.Kaz Kylheku2021-06-281-5/+44
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch improves the constantp function dramatically. It now performs a full expansion of its argument, and recognizes all of the constant foldable functions that the compiler recognizes. * eval.c (const_foldable_s): New symbol variable. (const_foldable_hash): New static variable. (constantp_noex): Look up function in the hash table of const foldable functions, including in the case when it appears in a dwim form as in [+ 2 2] which is (dwim + 2 2). In this case, recursively check the arguments for constantp_noex. We get the hash table of foldable functions from the sys:%const-foldable% variable, which comes from an autoloaded module. (constantp): Fully expand the input form, not just m macroexpand. (eval_init): Register the const_foldable_s variable. * lisplib.c (constfun_instantiate, constfun_set_entries): New static functions. (lisplib_init): Register auto-loading of constfun module via new static functions. * stdlib/compiler.tl; Load the constfun module if %const-foldable% is not defined. (%const-foldable-funs%, %const-foldable%): Removed from here. * stdlib/constfun.tl: New file. (%const-foldable-funs%, %const-foldable%): Moved here. * txr.1: Documented changes to constantp.
* regex: exposing optimization pass a regex-optimizeKaz Kylheku2021-06-271-0/+45
| | | | | | | | | | | | * regex.c (regex_optimize): New static function, capturing the three optimization passes. (regex_compile): Code moved into regex_optimize. (regex_init): Remove sys:reg-optimize function. Register regex-optimize. * txr.1: Documented. * stdlib/doc-syms.tl: Updated.
* suffix functions: requirements change.Kaz Kylheku2021-06-261-13/+14
| | | | | | | | | | | | | | | | | The short-suffix and long-suffix functions will now return the suffix including the leading period. This was a suggestion from user Paul A. Patience, which is a good requirement. Since these functions were newly introduced just the last release, I'm not going to provide backwards compatibility switching for them. * stream.c (short_suffix, long_suffix): Duplicate the suffix starting at the dot, not dot + 1. * tests/018/path.tl: Test cases updated. * txr.1: Documentation updated.
* suffix functions: leading dot is not delimiterKaz Kylheku2021-06-261-4/+9
| | | | | | | | | | * stream.c (short_suffix, long_suffix): Do not treat the starting dot of the last componet as a suffix delimiter. * tests/018/path.tl: Test cases edited to reflect requirements change; new tests added. * txr.1: Updated.
* doc: fix while-match syntax.Kaz Kylheku2021-06-251-1/+1
| | | | | * txr.1: fix when-match appearing in place of while-match. Reported by Ray Perry.
* doc: election typo.Kaz Kylheku2021-06-251-1/+1
| | | | * txr.1: Under Listener, selection was mistyped as election.
* Version 264txr-264Kaz Kylheku2021-06-251-3/+3
| | | | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * stdlib/ver.tl: Bumped. * txr.vim, tl.vim: Regenerated. * protsym.c: Likewise.
* doc: standardize on "user-defined".Kaz Kylheku2021-06-241-7/+7
| | | | | * txr.1: Replace a few occurrences of "application-defined" with the more prevalent "user-defined", including in one heading.
* file layout: moving share/txr/stdlib to stdlib.Kaz Kylheku2021-06-241-3/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This affects run-time also. Txr installations where the executable is not in directory ending in ${bindir} will look for stdlib rather than share/txr/stdlib, relative to the determined installation directory. * txr.c (sysroot_init): If we detect relative to the short name, or fall back on the program directory, use stdlib rather than share/txr/stdlib as the stdlib_path. * INSTALL: Update some installation notes not to refer to share/txr/stdlib but stdlib. * Makefile (STDLIB_SRCS): Refer to stdlib, not share/txr/stdlib. (clean): In unconfigured mode, remove the old share/txr/stdlib entirely. Remove .tlo files from stdlib. (install): Install lib materials from stdlib. * txr.1: Updated documentation under Deployment Directory Structure. * share/txr/stdlib/{asm,awk,build,cadr}.tl: Renamed to stdlib/{asm,awk,build,cadr}.tl. * share/txr/stdlib/{compiler,conv,copy-file,debugger}.tl: Renamed to stdlib/{compiler,conv,copy-file,debugger}.tl. * share/txr/stdlib/{defset,doc-lookup,doc-syms,doloop}.tl: Renamed to stdlib/{defset,doc-lookup,doc-syms,doloop}.tl. * share/txr/stdlib/{each-prod,error,except,ffi}.tl: Renamed to stdlib/{each-prod,error,except,ffi}.tl. * share/txr/stdlib/{getopts,getput,hash,ifa}.tl: Renamed to stdlib/{getopts,getput,hash,ifa}.tl. * share/txr/stdlib/{keyparams,match,op,optimize}.tl: Renamed to stdlib/{keyparams,match,op,optimize}.tl. * share/txr/stdlib/{package,param,path-test,pic}.tl: Renamed to stdlib/{package,param,path-test,pic}.tl. * share/txr/stdlib/{place,pmac,quips,save-exe}.tl: Renamed to stdlib/{place,pmac,quips,save-exe}.tl. * share/txr/stdlib/{socket,stream-wrap,struct,tagbody}.tl: Renamed to stdlib/{socket,stream-wrap,struct,tagbody}.tl. * share/txr/stdlib/{termios,trace,txr-case,type}.tl: Renamed to stdlib/{termios,trace,txr-case,type}.tl. * share/txr/stdlib/{ver,vm-param,with-resources,with-stream}.tl: Renamed to stdlib/{ver,vm-param,with-resources,with-stream}.tl. * share/txr/stdlib/yield.tl: Renamed to stdlib/yield.tl. * share/txr/stdlib/{txr-case,ver}.txr: Renamed to stdlib/{txr-case,ver}.txr. * gencadr.txr: Update to stdlib/place.tl. * genman.txr: Update to stdlib/cadr.tl.
* matcher: new looping macros.Kaz Kylheku2021-06-241-0/+109
| | | | | | | | | | | | | | * lisplib.c (match_set_entries): Autoload on new while-match, while-match-case and while-true-match-case symbols. * share/txr/stdlib/match.tl (while-match, while-match-case, while-true-match-case): New macros. * tests/011/patmatch.tl: Tests. * txr.1: Documented. * share/txr/stdlib/doc-syms.tl: Updated.
* New: stack overflow protection.Kaz Kylheku2021-06-231-0/+80
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * configure: detect getrlimit, producing HAVE_RLIMIT in config.h. * eval.c (do_eval, do_expand): Call gc_stack_check inline function to check stack pointer against limit. * gc.c (gc_stack_bottom): Static becomes extern, so inline function in gc.h can refer to it. (gc_stack_limit): New global variable. (gc_init): If we have rlimit, then probe RLIMIT_STACK. If the stack is sufficiently large, then enable the stack overflow protection, which kicks in when the stack pointer appears to be within a certain percentage of the limit. (set_stack_limit, get_stack_limit): New static functions. (gc_late_init): Register set-stack-limit and get-stack-limit intrinsics. (gc_stack_overflow): New function. * gc.h (gc_stack_bottom, gc_stack_limit, gc_stack_overflow): Declared. (gc_stack_check): New inline function. * lib.c (stack_overflow_s): New symbol variable. (obj_print_impl): Call gc_stack_check to protect recursive printing againts overflow. * lib.h (stack_overflow_s): Declared. * unwind.c (uw_init): Register stack-overflow symbol as a an exception symbol subtyped from error. (uw_unwind_to_exit_point): When dealing with an unhandled exception, turn off the stack limit, so we can print the messages without triggering it in a loop. * vm.c (vm_execute_closure, vm_funcall_common): Insert gc_stack_check to the top of the execution of every VM function. * txr.1: Documented. * share/txr/stdlib/doc-syms.tl: Updated.
* short-suffix, long-suffix: no match across slash.Kaz Kylheku2021-06-221-6/+40
| | | | | | | | | | | * stream.c (short_suffix, long_suffix): Take path separator characters into account; the suffix must not span across separators. The trailing separator must also not appear in the suffix. * tests/018/path.tl: Test cases added. * txr.1: Redocumented.
* New functions: long-suffix, short-suffix.Kaz Kylheku2021-06-221-0/+62
| | | | | | | | | | | | | | * stream.c (short_suffix, long_suffix): New functions. (stream_init): short-suffix and long-suffix intrinsics registered. * stream.c (short_suffix, long_suffix): Declared. * tests/018/path.tl: New file. * txr.1: Documented. * share/txr/stdlib/doc-syms.tl: Updated.
* doc: formatting in quasiquote pattern matching.Kaz Kylheku2021-06-221-1/+1
| | | | | | * txr.1: Remove stray space in marking up the JSON hash pattern syntax. This space has no ill effect when reading the man page via nroff, but messes up HTML rendering.
* Dubious new functions cxr/cyr.Kaz Kylheku2021-06-211-0/+52
| | | | | | | | | | | | | | * lib.c (cxr, cyr): New functions. * lib.h (cxr, cyr): Declared. * eval.c (eval_init): Intrinsics cxr and cyr registered. * tests/012/cadr.tl: New file. * txr.1: Documented. * share/txr/stdlib/doc-syms.tl: Updated.
* glob: support sequence of patterns argument.Kaz Kylheku2021-06-201-6/+32
| | | | | | | | | | | * glob.c (glob_wrap): Negate the GLOB_WRAP flag should it be present on input. If the input is a string, process it much like before. Otherwise loop over the pattern and call globl multiple times, adding the GLOB_APPEND flag for the second and subsequent times, and breaking out of the loop if a control transfer is detected. * txr.1: Document.
* doc: recent typo.Kaz Kylheku2021-06-201-1/+1
| | | | | | * txr.1: Fix typo introduced during recent work related to txr-case. aspell caught this but I overwrote the fix with a stale edit buffer.
* read/get-json: reject trailing junk in string input.Kaz Kylheku2021-06-201-1/+17
| | | | | | | | | | | | | | | | | * parser.c (lisp_parse_impl): If parsing from string, check for trailing junk and diagnose. JSON parsing doesn't use lookahead because it doesn't have a.b syntax, so the recent_tok gives the last token that actually went into the syntax, and not a lookahead token. So in the case of JSON, we call yylex to see if there is any trailing token. * tests/010/json.tl: Extend get-json tests to more kinds of objects, and then replicate with trailing whitespace and trailing junk to provide coverage for these cases. * tests/012/parse.t: Slew of new read tests and iread also. * txr.1: Documented.
* Version 263txr-263Kaz Kylheku2021-06-171-3/+3
| | | | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Bumped. * txr.vim, tl.vim: Regenerated. * protsym.c: Likewise.
* doc: bad grammar under FFI ptr typeKaz Kylheku2021-06-171-1/+1
| | | | * txr.1: "update *the* datum".
* doc: formatting of meta-symbols under op.Kaz Kylheku2021-06-171-16/+26
| | | | | | * txr.1: Fix the typesetting of @rest, @rec, @num, @n and @n-1 in the op macro section. Missing word inserted: "recursive call *to* the function".
* New macro: flow.Kaz Kylheku2021-06-161-0/+40
| | | | | | | | | | | | | | | There has been interest in the community in a threading macro; a triviality which which applies the opip syntax to a value. Eschewing unusual glyph combinations like ->> and whatnot, I've chosen the English word flow for this. * share/txr/stdlib/op.tl (flow): New macro. * lisplib.c (op_set_entries): Set up autoload for flow. * txr.1: Documented. * share/txr/stdlib/doc-syms.tl: Updated.
* listener: new --noprofile option.Kaz Kylheku2021-06-161-1/+9
| | | | | | | | | | | | | * parser.c (repl): Set the rcfile variable to nil if opt_noprofile is true, to suppress reading it. * txr.c (op_noprofile): New global variable. (help): Add help text. (txr_main): Recognize noprofile option and set variable. * txr.h (opt_noprofile): Declared. * txr.1: Documented.
* txr-case: upkeep.Kaz Kylheku2021-06-161-5/+33
| | | | | | | | | | | | | | | | | | | * share/txr/stdlib/txr-case.tl (txr-case-impl): If the input is a stream, then convert it to a lazy list of lines, so that running multiple functions against it produces sane, backtracking behavior, like a @(cases) construct. * tests/011/txr-case.expected: Updated. * tests/011/txr-case.txr: Now actually contains a test case for txr-case. * txr.1: Address an issue reported by Paul A. Patience: the input to match-fun, txr-if and txr-when may be a stream. That has always been the case in the implementation. Also document that when the input is a single string, it is treated as a list. Document the new requirement in txr-case that a stream is converted into lazy list of lines.
* math: forbid dubious inequality comparisons.Kaz Kylheku2021-06-151-1/+1
| | | | | | | | | | | | | | | | | | | The issue, reported by Paul A. Patience, is that code like (< 1 "abc") is successfully producing a result. The root cause is that 1 is an iterable object, and so is treated as a sequence opposite to the "abc" operand. We should allow only true sequences in this situation. * arith.c (seq_lt_compat_check): New static function. Checks that neither of two sequences is SEQ_NOTSEQ or SEQ_HASHLIKE. (seq_lt, seq_le): Use seq_lt_compat_check to reject dubious inputs. * txr.1: Minor wording change in the related documentation, removing a gratuitous adjective. * tests/016/arith.tl: Inequality tests.
* defsymacro: regression: don't expand replacement.Kaz Kylheku2021-06-151-14/+29
| | | | | | | | | | | | | | | | | | | | | | | | | | This is a regression that was introduced in 191. The change in 191 was trying to prevent defsymacro from being expanded immediately by the expander except in 190 compatibility. Unfortunately, this caused the whole defsymacro block not to be entered unless in 190 compatibility, otherwise taking the common exit which returns form_ex, containing the expanded replacement form. * eval.c (do_expand): Split up implementation of defvarl and defsymacro. In the defsymacro block, do not do any expanding on entry. Absent of compatibility mode, we just do some sanity checks and pass the entire form through. In 262 compatibility, we do the expansion to obtain form_ex. Then all the previous compat logic is wrapped in that block. * tests/011/macros-3.tl: Add a test case which confirms that symbol macros are lazily expanded. Weakness in the test suite is how these regressions creep in. * txr.1: Improve defsymacro documentation, spelling out clearly that the unexpanded replacement form is associated with the symbol. Eliminate obsolescent text suggesting that defsymacro is evaluated at macro time.
* txr.1: Correction to compat note for 190.Kaz Kylheku2021-06-151-1/+14
| | | | | | | | * txr.1: When writing up the compatibility notes for version 190, I missed the change that defmacro and defsymacro were switched away from instant evaluation by the macroexpander. That change introduced a regression which I just noticed, and this is noted also.
* doc: problems in mkstempKaz Kylheku2021-06-151-3/+3
| | | | | * txr.1: mkstemp: fix formatting problem in heading, and incorrect reference to mkdtemp with bad grammar.
* streams: *stdnull* lazily opens /dev/nullKaz Kylheku2021-06-141-3/+30
| | | | | | | | | | | | | | | | | | | | | The *stdnull* stream has been purely a stream-level abstraction. To make it useful for redirecting real file descriptors around the execution of external programs, we endow it with the ability to open /dev/null when it is asked to provide its file descriptor. * stream.c (struct dev_null): New structure. (dev_null_close, dev_null_get_fd, dev_null_get_prop): New static functions. (null_ops): Wire in the above functions instead of null_close, null_get_fd and null_get_prop. We need new functions because null_close and others do not belong to just the null stream; they are base operations used by other streams as default implementations for some kinds of unimplemented functions. (make_null_stream): Alocate a struct dev_null instead of a struct strm_base. Set the fd to -1. * txr.1: Documented.
* format: revise numeric handling.Kaz Kylheku2021-06-141-72/+112
| | | | | | | | | | | | | | | | | | | | | | | There are a number of issues, such as left adjustment not working and such. This needs a better treatment from the requirements level, through to a set of test cases. * stream.c (max, min): Macros macros added, in their usual form. (vformat_num): Implement new rules which suppress the zero and space characters used in place of a sign if they overflow the field width. (formatv): Clamp integer precision field to width - 1 for integers, for consistency with floating-point handling. For floating-point values under ~a and ~s, do not force the second stage precision to width - 1; only clamp it if it is greater. * format.tl: Numerous new tests. * txr.1: Significant redocumenting of this area. The handling of numbers is described as a two stage process, clarifying the changing role of "precision" in the two stages.
* format: new precision - character for zero.Kaz Kylheku2021-06-141-0/+12
| | | | | | | | | | | * stream.c (formatv): The - precision option character produces a "sign" that is a zero. If this is used with leading zeros, it will avoid generating a space. The requirements can use improvement here, but one step at a time. * tests/018/format.tl: Some tests. * txr.1: Documented.
* doc: remove hyphenation.Kaz Kylheku2021-06-141-4/+4
| | | | * txr.1: non-negative changed to nonnegative.
* Version 262txr-262Kaz Kylheku2021-06-111-3/+3
| | | | | | | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Bumped. * txr.vim, tl.vim: Regenerated. * protsym.c: Likewise. * y.tab.c.shipped: Regenerated. Good catch! forgot to do this for most recent change to parser.y.
* doc: add pic examples.Kaz Kylheku2021-06-111-0/+37
| | | | * txr.1: Examples added.
* pic: support quasiliteral as format string.Kaz Kylheku2021-06-111-6/+45
| | | | | | | | | | | | * share/txr/stdlib/pic.tl (pic): Refactor string compilation code into local function which has access to the overall argument list. Recognize the quasiliteral case and translate by compiling all the string parts, then forming a recombined quasiliteral where the compiled parts are substituted. * tests/018/format.tl: test case for this. * txr.1: Documented.
* doc: codify optional alternatives notation.Kaz Kylheku2021-06-111-1/+7
| | | | | | | * txr.1: The notation [ a | b | c | .. ] is used throughout the document, but the Conventions paragraph describes only square brackets around a single optional element. The notation is now officially codified.
* pic: allow trailing exclamation.Kaz Kylheku2021-06-111-14/+23
| | | | | | | | | | * share/txr/stdlib/pic.tl (expand-pic-num, expand-pic, pic): Allow ### to be followed by a single !. This is not counted toward the field width. * tests/018/format.tl: Cover with some tests. * txr.1: Doc updated.
* pic: clarification and tests.Kaz Kylheku2021-06-111-3/+7
| | | | | | | | * tests/018/format.tl: Add tests which combine overflow flagging with +/-. The space generated by - contributes to overflow. * txr.1: Clarify overflow issue in documentation.
* doc: document pic macro.Kaz Kylheku2021-06-101-0/+193
| | | | | | * txr.1: pic macro documented. * share/txr/stdlib/doc-syms.tl: Updated.
* format: fix precision field leading zero problems.Kaz Kylheku2021-06-101-6/+18
| | | | | | | | | | | | | | | | | * stream.c (formatv): Do not recognize multiple leading zeros as a single one; once the zero flag is set, if another zero is seen, it must be treated as one of the digits specifying the precision value. New requirement: before processing a format specifier, check for the situation that the leading zero has been specified, but no precision. Convert this situation to that of a precision of zero being given, with no leading zero. * txr.1: Document the ambiguity around the leading zero and how it is being handled when only the leading zero flag is given, and no actual precision. Add a note about what happens when zero precision is specified in ~a in conjunction with a floating-point value. Misspelled "pas" word fixed.
* arith: switch sum and prod to seq_iter.Kaz Kylheku2021-06-091-1/+3
| | | | | | | | | | | | | | * arith.c (nary_op_keyfun): Static function removed. (nary_op_seq, nary_op_seq_keyfun): New static functions. (sumv, prodv): Static functions removed. (sum, prod): Reimplement using nary_op_seq and nary_op_seq_keyfun. Conversion of sequence to list smuggled via args is gone. * tests/016/arith.tl: new sum and prod tests. * txr.1: Note about sum and prod taking an iterable sequence added.
* reduce-left: rewrite using seq_iter.Kaz Kylheku2021-06-091-0/+12
| | | | | | | * lib.c (reduce_left): Use sequence iteration instead of list operations. * txr.1: Add a note to the documentation.