summaryrefslogtreecommitdiffstats
path: root/txr.1
Commit message (Collapse)AuthorAgeFilesLines
...
* New functions: trim-short-suffix, trim-long-suffix.Kaz Kylheku2021-07-101-0/+59
| | | | | | | | | | | | | | | * lib.c, lib.h (chk_substrdup): New function. * stream.c, stream.h (trim_short_suffix, trim_long_suffix): New functions. (stream_init): trim-short-suffix and trim-long-suffix intrinsics registered. * tests/018/path.tl: New tests. * txr.1: Documented. * stdlib/doc-syms.tl: Updated.
* lib: new function separate.Paul A. Patience2021-07-091-1/+41
| | | | | | | | | | | | * lib.c (separate): New function. * lib.h (separate): Declared. * eval.c (eval_init): Register separate intrinsic. * txr.1: Documented. * stdlib/doc-syms.tl: Updated.
* defstruct: diagnose built-in type being redefined.Kaz Kylheku2021-07-091-0/+15
| | | | | | | | | | | | | | | | | | * eval.c (eval_init): Register built-in-type-p intrinsic. * lib.c (buitin_type_p): Rename to built_in_type_p since the word built-in is hyphenated. The function also tests whether the argument is a COBJ class. (cobj_class_exists): Function removed. * stdlib/doc-syms.tl: Updated. * stdlib/struct.tl (defstruct): Add built-in-type-p check. * struct.c (make_struct_type): Call only built_in_type_p; cobj_class_exists is gone. * txr.1: Document built-in-type-p.
* struct: rework stype_handle change.Kaz Kylheku2021-07-091-17/+20
| | | | | | | | | | | | | | | | | | | | | | | The change which allows stype_handle to recognize struct instances, and obtain their type, has some possibly unwanted ramifications, since the function is widely used. Let's refactor things so that, for now, only the struct_type_name function takes advantage of this flexibility. * struct.c (stype_handle_impl): New static function, copy of stype_handle, but taking an obj_ok Boolean argument to indicate whether an object instance is an acceptable argument, whose type should be fetched. (stype_handle): Now a wrapper around stype_handle_impl passing nil for the obj_ok argument. (stype_handle_obj): New static function. Passes t for the ok_obj argument of stype_handle_impl. (struct_type_name): Call stype_handle_obj instead of stype_handle. (super): Take advantage of stype_handle_obj to reduce code. * txr.1: Update documentation of struct-type-name, and improve that of super.
* with-resources: undocumented nil skip behavior.Kaz Kylheku2021-07-071-2/+29
| | | | | | | | | | | | | | | Paul A. Patience discovered the hidden "feature" of with-resourcers, that the three-argument form of the binding (var init cleanup) causes the with-resources form to terminate if init returns nil. The (var init) syntax doesn't generate this logic. * stdlib/with-resources.tl (with-resources): Do not emit the when form unless <= 265 compatibility is in effect. * tests/012/oop-mac.tl: New file. * txr.1: Compat note added.
* doc: base-name: nil suffix defaulting, improvement.Kaz Kylheku2021-07-061-5/+52
| | | | | | * txr.1: Document that the suffix argument to base-name may be given as nil, which is the same as omitting it. Nearby wording improved. Give rationale for this, and add examples.
* Version 265.txr-265Kaz Kylheku2021-07-041-3/+3
| | | | | | | | | | | | | | * RELNOTES: Updated. * configure (txr_ver): Bumped version. * stdlib/ver.tl (lib-version): Bumped. * txr.1: Bumped version and date. * txr.vim, tl.vim: Regenerated. * protsym.c: Likewise.
* listener: treat unset and empty EDITOR the same.Paul A. Patience2021-07-041-1/+1
| | | | | | | * linenoise/linenoise.c (edit_in_editor): Treat empty EDITOR variable as if it were unset (i.e., do nothing). * txr.1: Documented.
* doc: check for spurious spaces.Paul A. Patience2021-07-041-4/+4
| | | | | | | | | | | * checkman.txr (check-spaces): New pattern function for checking for spurious spaces (i.e., two spaces or more in a row) in .meIP, .meti and .mets macros. * txr.1: Fix two instances of spurious spaces ("@\ newline" and "@\ space" examples). Conform the "@\x hex-digits" and "@\ octal-digits" examples to the fixed ones; this is more intuitive since there must be no space before the digits in the escape sequence.
* stack-limit: impose minimum limit.Kaz Kylheku2021-07-041-5/+9
| | | | | | | | | | | | | * gc.c (MIN_STACK_LIMIT): New preprocessor symbol. (gc_init): If the system stack limit is too low, don't treat that the same way as a missing or unlimited limit. Instead clamp to the minimum value and hope for the best. So that is to say, the system limit cannot be used as a mechanism to set a ridiculously low stack limit in TXR; the only way to do that is to use the set-stack-limit function. * txr.1: Documentation updated. Also fixed 326767 typo which should be 32767.
* suffix functions: ignore trailing slashes.Kaz Kylheku2021-07-031-4/+7
| | | | | | | | | | | | | | | | Another requirements tweak to short-suffix and long-suffix: ignore one or more trailing slashes, instead of just one. This harmonizes with base-name, which does same, that requirement being copies from the POSIX basename utility. * stream.c (short_suffix, long_suffix): If sl points to a trailing slash which is the start of a suffix that consists of nothing but trailing slashes, then we pretend it isn't there. * tests/018/path.tl: Adjusted two existing test cases, and added more. * txr.1: Documented.
* doc: find-true spelling error.Kaz Kylheku2021-07-031-1/+1
| | | | | * txr.1: Fix "funtion" in description of new find-true function.
* doc: fix description and example of suffix funsPaul A. Patience2021-07-031-2/+2
| | | | | | | * txr.1: The suffix of path "abc." is ".". Fix the description for this case (which suggested the suffix was the empty string, which was the case before commit bf2e5199e8dbc4e6fd4fcac5dab1ea16f4ec5970) and one of the examples.
* doc: fix various issues.Paul A. Patience2021-07-031-592/+685
| | | | | | | | | | | | | | | | | | | * RELNOTES: Fix typos. * txr.1: Correct alist-remove and alist-nremove's argument lists (the keys are variadic). Remove "(the empty string)" from abs-path-p examples because it formats bizarrely in man output and is anyway mentioned in the description. Remove spurious spaces from .mets lines interfering with the formatting. Add some missing .code and .meta directives. Unitalicize words of Latin origin that have entered the dictionary ("de facto" and "vice versa"). Add hyphens to compound words used as adjectives. Remove hyphen from "non-matching". Move periods inside parentheses containing full sentences. Add missing words. Remove repeated words. Fix various other minor issues. * txr.c (help): Fix a typo. Clarify a description. Add missing periods. Make some other minor changes.
* 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.