summaryrefslogtreecommitdiffstats
path: root/txr.1
Commit message (Collapse)AuthorAgeFilesLines
* doc: macrolet doesn't contain top-level forms.Kaz Kylheku2021-05-171-0/+28
| | | | | | * txr.1: For eval and for compilation, document that symacrolet and macrolet do not enclose multiple top-level forms.
* doc: deindent top-level form rules.Kaz Kylheku2021-05-171-1/+0
| | | | | * txr.1: Because we are not in indented paragraphs, we don't need the opening .RS.
* doc: a round of documentation fixes.Paul A. Patience2021-05-171-98/+190
| | | | | * txr.1: Hyphenation, punctuation, spelling and formatting throughout document.
* doc: incorrect precedence of repeat special clauses.Kaz Kylheku2021-05-171-16/+28
| | | | | | | | | * txr.1: The precedence among the repeat clauses is documented incorrectly: the @(mod) clause has a lower precedence than modlast and last. Redocumenting this area for better clarity, and mentioning why @(empty) isn't in the precedence list. This issue was reported by Paul A. Patience with a patch, which I reworked.
* doc: deffi, defplace: syntax heading.Paul A. Patience2021-05-171-4/+4
| | | | | | * txr.1: Use let-like small indentation for the clauses of defplace. Formatting adjusted slightly by K. K. Remove spurious defmacro element in deffi syntax.
* doc: rewrite flawed doc for sme operator.Kaz Kylheku2021-05-161-15/+42
| | | | | | | * txr.1: The documentation of the semantics of sme contradicts itself by neglecting to specify that the middle part of the input is searched for match for the middle pattern mpat. Let's fix this by giving detailed semantics in bulleted form.
* compiler: better code for global var definitions.Kaz Kylheku2021-05-141-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | * eval.c (rt_defvarl): More accurate self string. (rt_defv): New static function: like rt_defvarl but ensures that the new variable has a binding cell, and returns that cell instead of the hash cell. (op_defvarl): Take advantage of rt_defv to not have to cons up the binding cell. (eval_init): Register sys:rt-defv intrinsic. * parser.c (read_file_common): Compiled files are now version 7, so we must recognize them. We still load version 6 files because rt:defvarl still exists for them. * share/txr/stdlib/compiler.tl (expand-defvarl): Improve the generated code in two ways. Firstly, use the new sys:rt-defv, which returns the binding cell, so that the value can be stored into it with rplacd without having to cons up anything. Secondly, if there is no value expression, don't emit the code to do the assignment. (%tlo-ver%): Bump compiled file version to (7 0). * txr.1: Add note about TXR 260 loading version 7 and 6.
* Version 259txr-259Kaz Kylheku2021-05-131-3/+3
| | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Bumped. * txr.vim, tl.vim: Regenerated.
* doc: show .tlo files in deployment example.Kaz Kylheku2021-05-121-0/+2
| | | | | * txr.1: The example deployment structure shows only .tl files. Add a .tlo in there.
* tree: let tree-iter be iterable via generic iteration.Kaz Kylheku2021-05-121-0/+21
| | | | | | | | | | * lib.c (seq_iter_init_with_info): Recognize tree_iter object, and treat using tree iterator function. * tests/010/tree.tl: test case for tree subrange iteration with collect-each. * txr.1: Updated.
* doc: nonexistent tree-value-atKaz Kylheku2021-05-111-2/+2
| | | | * txr.1: Fix typos: tree-value-at should be trie-value-at.
* tree: streamline iteration; provide high limit.Kaz Kylheku2021-05-111-73/+44
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Getting rid of tree-begin-at and tree-reset-at. Now tree-begin takes two optional parameters, for specifying high and low range. * tree.c (struct tree_diter): New members, tree and highkey. We need tree due to requiring access to the less function. If the iterator has no highkey, the iterator itself is stored in that member to indicate this. (tree_iter_mark): Mark the tree and highkey. (tree_begin): Take optional lowkey and highkey arguments, initializing iterator acordingly. (tree_begin_at): Function removed. (copy_tree_iter, replace_tree_iter): Copy tree and highkey members. The latter require special handling due to the funny convention for indicating highkey absence. (tree_reset): Take optional lowkey and highkey arguments, configuring these in the iterator being reset. (tree_reset_at): Function removed. (tree_next, tree_peek): Implement highkey semantics. (sub_tree): Simplified: from and to arguments are just passed through to tree_begin, and there is no need for a separate loop which enforces the upper limit, that now being handled by the iterator itself. (tree_begin): Update registrations of tree-begin and tree-reset; remove tree-begin-at and tree-reset-at intrinsics. * tree.h (tree_begin_at, tree_reset_at): Declarations removed. (tree_begin, tree_reset): Declarations updated. * lib.c (seq_iter_rewind, seq_iter_init_with_info, where, populate_obj_hash): Default new optional arguments in tree_begin and tree_reset calls. * parser.c (circ_backpatch): Likewise. * tests/010/tree.tl: Affected cases updated. * txr.1: Documentation updated. * share/txr/stdlib/doc-syms.tl: Regenerated.
* tree: support indexing and range extraction.Kaz Kylheku2021-05-111-0/+75
| | | | | | | | | | | | | | | | | | | * lib.c (do_generic_funcall): Support tree object invocation with one or two arguments via sub and ref. (sub): Implement for trees via sub_tree. (ref): Implement for trees via tree_lookup. * tree.c (sub_tree): New function. (tree_init): Register sub-tree intrinsic. * tree.h (sub_tree): Declared. * tests/010/tree.tl: New tests. * txr.1: Documented: DWIM bracket syntax on trees, sub and ref support for trees, sub-tree function, * share/txr/stdlib/doc-syms.tl: Regenerated.
* tree: replace-tree-iter function.Kaz Kylheku2021-05-111-0/+31
| | | | | | | | | | | | | * tree.c (replace_tree_iter): New function. (tree_init): Register replace-tree-iter intrinsic. * tree.h (tree_init): Declared. * share/txr/stdlib/doc-syms.tl: Updated. * txr.1: Documented. * tests/010/tree.tl: New test case.
* tree: copy-tree-iter function.Kaz Kylheku2021-05-101-0/+25
| | | | | | | | | | | | | | | * lib.c (copy): Handle tree_iter_s via copy_tree_iter. * tree.c (copy_tree_iter): New function. (tree_init): copy-tree-iter intrinsic registered. * tree.h (copy_tree_iter): Declared. * tests/010/tree.tl: New test case. * txr.1: Documented. * share/txr/stdlib/doc-syms.tl: Updated.
* doc: fix out of order compat notes.Kaz Kylheku2021-05-101-23/+23
| | | | | * txr.1: Move compatibility notes 258, 257 and 231 to the correct position, so the numbers are descending.
* tree: new tree-peek function.Kaz Kylheku2021-05-091-10/+29
| | | | | | | | | | | | | | * tree.c (tn_peek_next): New static function. (tree_peek): New function. (tree_init): Register tree-peek intrinsic. * tree.h (tree_peek): Declared. * txr.1: Documented. * tests/010/tree.c: Work tree-peek into existing test case. * share/txr/stdlib/doc-syms.tl: Updated.
* tree: new make_similar_tree unction.Kaz Kylheku2021-05-091-0/+17
| | | | | | | | | | | * tree.c (make_similar_tree): New function. (tree_init): Register make-similar-tree intrinsic * tree.h (make_similar_tree): Declared. * tests/010/tree.tl: New tests. * txr.1: Documented.
* matcher: new "each-match family" of macros.Kaz Kylheku2021-05-041-0/+232
| | | | | | | | | | | | | | | | | | * lisplib.c (match_set_entries): New autoload symbols: each-match, append-matches, keep-matches, each-match-product, append-match-products, keep-match-products. * share/txr/stdlib/doc-syms.tl: Updated. * share/txr/stdlib/match.tl (each-match-expander): New function. (each-match, append-matches, keep-matches, each-match-product, append-match-products, keep-match-products): New macros. * tests/011/patmatch.tl: New tests covering each macro, far from exhaustively. * txr.1: Documented.
* format: ~x/~X specifiers support buffers.Kaz Kylheku2021-05-041-5/+4
| | | | | | | | | | | | | * buf.c (buf_hex): New function. * buf.h (buf_hex): Declared. * stream.c (formatv): Support printing of buffers in hex via temporary buffer containing hex characters, similarly to how bignums are handled. * tests/018/format.tl: New file, providing some coverage over new and affected code.
* rel-path: bugfixes.Kaz Kylheku2021-05-031-11/+116
| | | | | | | | | | | | | | | * share/txr/stdlib/copy-file.tl: When removing .. components, a dotdot must only cancel preceding non-dotdot. We must check not only that the out stack is not empty but that the top element isn't dotdot. Also, eliminate empty components, like the documentation says. Lastly, we must check for the impossible cases, when the from path uses .. components that are impossible to navigate backwards to form a relative path. * tests/018/rel-path.tl: Test cases added. * txr.1: Updated with additional descriptions, fixes and examples.
* New function: rel-path.Kaz Kylheku2021-05-031-0/+99
| | | | | | | | | | | | | * lisplib.c (copy_file_set_entries): Add rel-path as autoload trigger for copy-file module. * share/txr/stdlib/copy-file.tl (rel-path): New function. * tests/018/rel-path.tl: New file. * txr.1: Documented. * share/txr/stdlib/doc-syms.tl: Updated.
* New function: portable-abs-path-p.Kaz Kylheku2021-05-021-5/+31
| | | | | | | | | | | | | | | * share/txr/stdlib/doc-syms.tl: Updated. * stream.c (portable_abs_path_p): New function, exact copy of old abs_path_p. (abs_path_p): Rewritten to be specific to host platform. No Windows-drive-like prefixes are checked on POSIX. (stream_init): Register new function. Register abs-path-p conditionally based on 258 compatibility. * stream.h (portable_abs_path_p): Declared. * txr.1: Documented, with compat notes.
* doc: "suficient" typo in new paragraph.Kaz Kylheku2021-05-021-1/+1
| | | | | * txr.1: Fix typo in recently introduced paragraph about file compiler's treatment of symbols.
* Version 258txr-258Kaz Kylheku2021-05-011-3/+3
| | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Bumped. * txr.vim, tl.vim: Regenerated.
* doc: note a diff between compiled and source files.Kaz Kylheku2021-04-301-0/+42
| | | | | | * txr.1: A new paragraph about how symbols are treated: source files can refer to unqualified symbols, but compiled files do not.
* tree: new functions for reseting iterator.Kaz Kylheku2021-04-301-0/+51
| | | | | | | | | | | | | | * tree.c (tree_reset, tree_reset_at): New functions. (tree_init): tree-reset and tree-reset-at intrinsics registered. * tree.h (tree_reset, tree_reset_at): Declared. * tests/010/tree.tl: New tests. * txr.1: Documented. * share/txr/stdlib/doc-syms.tl: Updated.
* tree: new tree-begin-at function.Kaz Kylheku2021-04-291-3/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * tree.c (enum tree_iter_state): New iterator state tr_find_low_prepared dedicated to the tree-begin-at traversal. This state indicates that tree-next should visit the starting node that it is given, and then after that, treat anything to the left of it as having been visited. In the other states, tree-next does not visit the node it is given but uses it as the starting point to find the next node. (tn_find_next): Bugfix here: when navigating the right link, the function neglected to add the node to the path. But the logic for backtracking up the path expects this: it checks whether the node from the path is the parent of a right child. Somehow this didn't cause a problem for full traversals with tree-begin; at least the existing test cases don't expose an issue. It caused a problem for tree-begin-at, though. (tn_find_low): New static function. This finds the low-key node in the tree, priming the iterator object with the correct state and path content to continue the traversal from that node on . We need the tr_find_low_prepared state in the iterator in order to visit the low node itself that was found. (tree_begin_at): New function. (tree_init): Register tree-begin-at intrinsic. * tree.h (tree_begin_at): Declared. * tests/010/tree.tl: New test cases for tree-begin-at. * txr.1: Documented. * share/txr/stdlib/doc-syms.tl: Updated.
* doc: wrong heading for tree-insertKaz Kylheku2021-04-291-1/+1
| | | | * txr.1: Fix tree-insert being under tree-insert-node heading.
* macros: lexical-var-p: don't report t for specials.Kaz Kylheku2021-04-281-4/+52
| | | | | | | | | | | | | | | | | | | | The lexical-var-p function wrongly reports true for locally rebound special variables, which are not lexical. * eval.c (special_var_p): Static function moved to avoid forward declaration. (lexical_var_p): Bail if sym satisfies special_var_p. (old_lexical_var_p): New function, copy of old lexical_var_p before this bugfix. (eval_init): Conditionally register lexical-var-p as either lexical_var_p or old_lexical_var_p depending on the compat value. * txr.1: Update documentation for lexical-var-p to clarify that it doesn't report true for specials. Also make note that it doesn't report true for global lexicals, and likewise that lexical-fun-p doesn't report global functions. Added compat note.
* doc: document seq-iter type and redocument iter-beginKaz Kylheku2021-04-281-10/+30
| | | | | | * txr.1: mention seq-iter in the type hierarchy diagram. The documentation for iter-begin is revised, and now mentions that the returned value is of this type in some cases.
* doc: document --free-allKaz Kylheku2021-04-261-0/+9
| | | | | * txr.1: the --free-all command line option appeared in TXR 144 in 2016, but was never documented.
* match-str: return useful position instead of t.Kaz Kylheku2021-04-261-6/+20
| | | | | | | * lib.c (match_str): The match_str function is hereby altered to return an integer instead of the symbol t in the matching case. * txr.1: Updated.
* doc: document quasiliteral matchingKaz Kylheku2021-04-261-6/+202
| | | | | | * txr.1: New operator <2> for meta-syntax, used when two italicized terms are sandwiched in three non-italicized terms. Documented quasiliteral matching.
* Version 257txr-257Kaz Kylheku2021-04-231-3/+3
| | | | | | | | | | | | | | | | | Log message correction superseding original commit 65213f5f7f6a204886a02c32f259ae2617d1dfb6. * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Bumped. * txr.vim, tl.vim: Regenerated. * protsymc.: Likewise * share/txr/stdlib/doc-syms.tl: Likewise.
* doc: remove hyphen from -s plurals.Kaz Kylheku2021-04-221-140/+140
| | | | | | | | | | * txr.1: After some some discussions with Paul A. Patience, I've decided to fix the instances where an identifier in italics or typewriter font is pluralized with -s to just use s. Some 140 instances are fixed. * checkman.txr: Allow exception for "s" in the rule that punctuation must follow codn/metn.
* matcher: defmatch: useful :env parameter.Kaz Kylheku2021-04-211-6/+48
| | | | | | | | | | | | | | | | | | | * share/txr/stdlib/match.tl (compile-match): Pattern macro expanders now have an environment parameter. We turn the list of variables that have been bound so far into a fake macro-time lexical environment, the parent of which is the surrounding environment. The pattern macro can query this using the lexical-var-p function to determine whether a given variable already has a binding, either in the pattern, or in the surrounding lexical environment. (defmatch): Generate a two-argument lambda, and use the new mac-env-param-bind to make the environment object available to the user-defined expansion. * tests/011/patmatch.tl: New test cases for this environment mechanism, and also for defmatch itself. * txr.1: Document role of :env under defmatch.
* compile/eval: new operator, mac-env-param-bind.Kaz Kylheku2021-04-211-8/+60
| | | | | | | | | | | | | | | | | | | | | | mac-env-param-bind is like mac-param-bind but also allows the value for the :env parameter to be specified. * eval.c (op_mac_env_param_bind_s): New sy mbol variable. (op_mac_env_param_bind): New static function. (do_expand): Handle mac_env_param_bind_s. (eval_init): Initialize symbol variable and register macro. * share/txr/stdlib/compiler.tl (compiler compile): Add case for mac-env-param-bind. (compiler comp-mac-env-param-bind): New method. * share/txr/stdlib/doc-syms.tl: Updated with new hashes for tree-bind and mac-param-bind, and inclusion of mac-env-param-bind. * tests/012/binding.tl: New file. * txr.1: Documented.
* matcher: new pattern operator @(end)Kaz Kylheku2021-04-201-0/+58
| | | | | | | | | | | | | | | * share/txr/stdlib/doc-syms.tl: New entry for end. * share/txr/stdlib/match.tl (check, check-end, check-sym, loosen, pat-len): New functions, taken from original local functions of sme macro. (sme): Refactored by hoisting local functions out. Some local variable renaming. (end): New pattern macro. * tests/011/patmatch.tl: New test for end. * txr.1: Documented.
* matcher: first pattern macro, sme.Kaz Kylheku2021-04-191-0/+125
| | | | | | | | | | | | * lisplib.c (match_instantiate): Intern sme symbol. * share/txr/stdlib/doc-syms.tl: Update with sme entry. * share/txr/stdlib/match.tl (sme): New defmatch macro. * tests/011/patmatch.tl: New tests for sme. * txr.1: Documented.
* doc: reversed maphash parameters.Kaz Kylheku2021-04-191-1/+1
| | | | | * txr.1: The function is first, then the hash. Reported by Ray Perry.
* defmatch: pass form to mac-param-bind.Kaz Kylheku2021-04-191-0/+22
| | | | | | | | * share/txr/stdlib/match.tl (defmatch): Pass *match-form* to mac-param-bind so that the context is available to defmatch macros via the :form parameter. * txr.1: Documented use of :form in defmatch.
* matcher: new @(scan) operator.Kaz Kylheku2021-04-181-0/+64
| | | | | | | | | | | | | | * share/txr/stdlib/match.tl (compile-scan-match): New function. (compile-match): Hook scan operator into compiler. * lisplib.c (match_set_entries): Ensure scan is interned in usr package. * txr.1: Documented. * share/txr/stdlib/doc-syms.tl: Updated with new entry for scan.
* matcher: allow user-defined patterns via defmatchKaz Kylheku2021-04-171-3/+94
| | | | | | | | | | | | | | | | | * lisplib.c (match_set_entries): Register defmatch and *match-symbol* to autoload match.tl. * share/txr/stdlib/doc-syms.tl: Updated with entries for defmatch and *match-macro*. * share/txr/stdlib/match.tl (*match-macro*): New special variable holding hash. (compile-match): Handle macros via *match-macro* hash. (defmatch): New macro. * txr.1: Documented. * tags.tl: Recognize defmatch forms.
* streams: revise stream-max-len over strings.Kaz Kylheku2021-04-171-14/+15
| | | | | | | | | | | | | | | | The maximum number of characters printed from a string is too small, if it is directly taken from the stream-max-len value. We are going to multiply it by 8, and clamp the minimum characters at 24. * lib.c (max_str_chars): New inline function. (lazy_str_put, out_lazy_str, out_quasi_str): Use inline function to determine maximum number of chracters to print. Also bugfix here: decrement and test max_chr in the loop, not max_len. This bug was copy-pasted across all these functions. (obj_print_impl): Similarly revise the printing of strings. * txr.1: Documentation updated.
* doc: implement typesetting of keystrokes.Kaz Kylheku2021-04-131-112/+423
| | | | | | | | | | | | | | | | | | | | This commit relies on parallel improvements in man2html, up through commit ac186529b6b5f80906c3215a67c98505db7bb156 "Implement .M2HT request for HTML passthrough." * genman.txr: Add CSS block targetting the kbd element, providing 3D styling for keyboard input. * txr.1: Define two new macros, .key and .keyn. These are defined in three different ways: in man page output, we put square brackets around keystrokes. In typeset groff output, we put a square border around them using a box macro cribbed from groff documentation. In HTML, we use .M2HT to wrap a <kbd> tag around the keystrokes. Documentatio is updated to use these macros for all keystrokes. We no longer separate keystroke sequence elements with commas.
* doc: redocument UTF-8 in source and literals.Kaz Kylheku2021-04-101-32/+48
| | | | | | | | | | | * txr.1: Because invalid UTF-8 bytes are allowed in string literals, that documentation needs to be updated. I'm rewriting it substantially to clarify the difference between text streams and parsing source. In the discussion of escape sequences in string literals, the wording is improved. Because the source code is UTF-8, we could plausibly support escapes which specify bytes (that are then decoded), so that's not the correct rationale for not supporting it.
* doc: remove some hyphenation.Kaz Kylheku2021-04-091-10/+10
| | | | | * txr.1: Do not hyphenate two's complement and C language, except in phrases like "C-language-style whatever".
* doc: lambda: add pointers to alternative notations.Kaz Kylheku2021-04-091-0/+75
| | | | | | * txr.1: Under the lambda operator, point to the op notational family, functional combinators and the OOP-related method and slot indirection.
* doc: more details in string literals section.Kaz Kylheku2021-04-091-0/+14
| | | | | * txr.1: advise user that numeric escapes in string literals are not byte-wise, but specify code points.