summaryrefslogtreecommitdiffstats
path: root/txr.1
Commit message (Collapse)AuthorAgeFilesLines
...
* doc: clarify implicit insertion object into predicate.Kaz Kylheku2021-02-091-1/+1
| | | | | * txr.1: Better wording is that the object is added as an implicit rightmost argument.
* doc: fix fumbled text under predicate pattern.Kaz Kylheku2021-02-091-1/+1
| | | | * txr.1: "three two" should be "second three".
* doc: with pattern operator clarification.Kaz Kylheku2021-02-091-2/+6
| | | | | * txr.1: Clarify that expr is not evaluated if the main-pattern fails to match.
* doc: double nil in list pattern description.Kaz Kylheku2021-02-091-1/+1
| | | | * txr.1: Fix "atom pattern nil nil".
* doc: fixes in pattern matching introduction.Kaz Kylheku2021-02-091-15/+17
| | | | | | | | * txr.1: Improving text about variables. Removing obsolete reference to parallel scoping behavior of @(and) and mentioning that @(as) binds fresh variables, which could cause multiple occurrences of a variable in the same patter not to refer to the same variable.
* struct: changing meaning of obj.[fun ...] syntax.Kaz Kylheku2021-02-091-13/+33
| | | | | | | | | | | | | | | | | | | | | | | | | Until now, the obj.[fun ...] syntax has uselessly denoted exactly the same thing as [obj.fun ...]. This latter syntax is what should be used for that meaning. The new meaning of obj.[fun ...] will be that it performs method dispatch, where obj is passed to obj.fun as the leftmost argument: obj.[fun ...] is [obj.fun obj ...], with obj evaluated once. * share/txr/stdlib/struct.tl (qref): Expansion change done here, with backward compat switch. * share/txr/stdlib/termios.tl (termios (go-raw, go-cbreak)): Some a.[b c] turned to [a.b c] here. * tests/012/oop.tl (animal print): Likewise. * tests/012/struct.tl: Likewise, and some expansion tests updated to reflect the new expansion. * txr.1: Documentation revised in multiple places and compat note added.
* Version 251txr-251Kaz Kylheku2021-02-081-4/+4
| | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Re-synced to 251. * txr.vim, tl.vim: Regenerated.
* doc: document feature of multi-sort.Kaz Kylheku2021-02-081-0/+4
| | | | | | * txr.1: Document that multi-sort takes a single function in place of a list of one function. This has been a feature of the implementation from the beginning.
* matcher: predicate: document dot position of @avar.Kaz Kylheku2021-02-061-5/+9
| | | | | * txr.1: The @avar variable may be in the dot position of the form, denoting application.
* matcher: remove @(op ...) pattern.Kaz Kylheku2021-02-061-32/+0
| | | | | | | | | | | | | | | All he typical uses of this are better served by the new predicate match. If op is really needed, it can be used with the DWIM form of the predicate, as in @[(op ...) ...]. * share/txr/stdlib/match.tl (compile-op-match): Function removed. (compile-match): Remove op case. * tests/011/patmatch.tl: Keep op test cases by converting them to predicate test cases. * txr.1: Documentation removed.
* matcher: redesign predicate pattern.Kaz Kylheku2021-02-061-62/+90
| | | | | | | | | | | | | | | | | | | | | | | | * share/txr/stdlib/match.tl (compile-dwim-predicate-match): Function removed. There is no more special @(dwim ...) or @[...] pattern. (compile-predicate-match): Function rewritten, providing different syntax and semantics. (compile-match): dwim dispatch removed. (non-triv-pat-p): Replaced @(op ...) calls with new-style predicate syntax. (var-pat-p): Likewise, and upgraded one instance of old-style predicate syntax to new. * share/txr/stdlib/compiler.tl (reduce-or): Adjust predicate pattern to new style. * share/txr/stdlib/optimize.tl (dedup-labels): Likewise. * tests/011/patmatch.tl: All test cases with predicate syntax are updated to new style. One test case removed; some added. * txr.1: Predicate patterns re-documented. All examples involving predicate patterns updated.
* matcher: left-to-right scoping for @(and).Kaz Kylheku2021-02-061-18/+29
| | | | | | | | | | | | | | And binds left to right now; only or is parallel. * share/txr/stdlib/match.tl (compile-and-mach): Do not compile the patterns with copies of the var list, but with he one and only incoming var-list. Consequently, there are not var lists to merge. par-pat parameter renamed to and-pat. * txr.1: Improve and/or documentation, clarifying scope rules. Also, clarify that variables in non-matching patterns of an or are no set to nil, if they are existing bindings from before the or.
* matcher: @(as) must always bind fresh variable.Kaz Kylheku2021-02-061-12/+31
| | | | | | | | | | | | | | It is documented that as binds a new variable. Furthermore, it used to be called let. Yet, it back-references. Let's fix it. * share/txr/stdlib/match.tl (compile-new-var-match): New function: like compile-var-match but binds new variable, as if back-referencing didn't exist. (compile-as-match): Use compile-new-var-match. * txr.1: Improve as documentation. Clarify that it binds a fresh variable, and that pattern is processed in its scope. Include an example with circular structure.
* matcher: back-reference Lisp variables.Kaz Kylheku2021-02-051-0/+25
| | | | | | | | | | | | | | | | * share/txr/stdlib/match.tl (struct var-list): New slot, menv. (var-list exists): Method now falls back on lexical scope and dynamic variables. (get-var-list): New function. (when-match, if-match, match-case, when-exprs-match): Capture macro environment and use get-vars-list to convert to a vars object which carries it as the menv slot. With this, the compiler framework has access to the lexical environment. * tests/011/patmatch.tl: Test cases of back-referencing with Lisp lexicals. * txr.1: Documented.
* matcher: rearrange match order of @(with).Kaz Kylheku2021-02-051-10/+22
| | | | | | | | | | | | | | | | | The @(with side-pat expr main-pat) syntax becomes @(with main-pat side-pat expr), which is more useful. Also, the main-pat can be omitted. * share/txr/stdlib/match.tl (compile-with-match): Recognize two forms of the syntax: two argument form with main-pat omitted and the full form. In the full form, main-pat is on the left now and processed first, so we have to rearrange the compilation and integration order. * tests/011/patmatch.tl: Existing tests updated. Two-argument test added. * txr.1: Updated.
* doc: misspelled dump-deferred-warningsKaz Kylheku2021-02-041-1/+1
| | | | * txr.1: pluralize identifier in syntax section.
* matcher: add :match parameter macro.Kaz Kylheku2021-02-041-4/+233
| | | | | | | | | | | | | With this, we can do matching anywhere we are able to specify a function parameter list and a body, and we can specify ordinary arguments, which are inserted to the left of the implicit match. Plus, it specialy integrates with :key. * lisplib.c (match_set_entries): Autoload on :match. * share/txr/stdlib/match.tl (:match): New parameter macro. * txr.1: Documented.
* doc: param macros: missing return value requirements.Kaz Kylheku2021-02-041-0/+14
| | | | | | * txr.1: Document return value convention of parameter list transformers, without which it can only be deduced from the example.
* matcher: lambda-match: redoc, bugfix, test-casesKaz Kylheku2021-02-041-36/+149
| | | | | | | | | | | | | | | * share/txr/stdlib/match.tl (expand-lambda-match): In a case that takes the maximum number of fixed args and no dotted pattern, in a function that is variadic, we must assert that the rest parameter is nil: there are no additional arguments. In the lambda args, we must generate the colon that separates the optional arguments. * tests/011/patmatch.tl: basic test cases for lambda-match and defun-match. * txr.1: lambda-match and defun-match redocumented, with examples.
* matcher: new @(with) operator.Kaz Kylheku2021-02-011-0/+46
| | | | | | | | | | | | * lisplib.c (match_instantiate): Ensure usr:with is interned. * share/txr/stdlib/match.tl (compile-with-match): New function. (compile-match): Wire in with operator. * tests/011/patmatch.tl: Test cases. * txr.1: Documented.
* matcher: rename @(let) to @(as).Kaz Kylheku2021-02-011-8/+8
| | | | | | | | | | | | | * lisplib.c (match_instantiate): Ensure usr:as is interned. * share/txr/stdlib/match.tl (compile-let-match): Rename to compile-as-match. (compile-match): Remove handling of let symbol; route as symbol to compile-as-match. * tests/011/patmatch.tl: Update all uses of let to as. * txr.1: Updated.
* doc: mistake in example for @[...] pattern.Kaz Kylheku2021-02-011-3/+3
| | | | | | | * txr.1: Fix use of nonexistent odd function which should be oddp. The same example occurs in the test suite, but without this error. Also fix indentation in this and the two related examples above.
* doc: mistake in when-match rcons example.Kaz Kylheku2021-02-011-1/+1
| | | | | * txr.1: The de-sugared (rcons @a @b) example is missing a quote on the object, and so returns nil and not (1 2).
* Version 250txr-250Kaz Kylheku2021-01-311-3/+3
| | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise. * txr.vim, tl.vim: Regenerated.
* @(rebind): bugfix: don't clobber right side variable.Kaz Kylheku2021-01-301-10/+66
| | | | | | | | | | | | | | | | | | | | | * Makefile (tst/tests/000/binding.ok): Pass -B to txr for this new test. * match.c (v_rebind): Fix gaping copy-and-paste bug here, which causes rebind to take on the behavior of local/forget; it takes all symbols that appear as its arguments from the environment and produces an environment in which they don't exist. What we want is to remove the left variables from the environment, and since that is a nested pattern, the right way to do that is to flatten it. Bug reported by Frank Schwidom. * tests/000/binding.txr: New file. * tests/000/binding.expected: New file. * txr.1: Improve documentation of @(rebind), also making improvements in @(set) documentation.
* doc: bad syntax formatting: partition and split.Kaz Kylheku2021-01-291-4/+4
| | | | | | * txr.1: Fix issues in the formatting of the index-list, index and function arguments of partition, partition*, split and split* functions.
* matcher: allow pat/var argument: @[expr var pat]Kaz Kylheku2021-01-261-8/+31
| | | | | | | | | | | | * share/txr/stdlib/match.tl (compile-dwim-predicate-match): Drop redundant bindable check of sym, since compile-var-match checks this. Support third argument which gives a pattern or variable which captures the value from the predicate function, which might be interesting (not just true/false). * tests/011/patmatch.tl: New tests. * txr.1: Documented.
* matcher: allow @[...] predicate notation.Kaz Kylheku2021-01-251-13/+25
| | | | | | | | | * share/txr/stdlib/match.tl (compile-dwim-predicate-match): New function. (compile-match): Route dwim symbol to compile-dwim-predicate-match. * txr.1: Documented.
* doc: update definition of non-trivial pattern.Kaz Kylheku2021-01-251-1/+1
| | | | | * txr.1: Under Pattern operator hash, include range patterns wih non-trivial contents as being non-trivial.
* doc: fix .meti not wrapped in of .mono/.onom.Kaz Kylheku2021-01-251-0/+32
| | | | | | | | | | * checkman.txr (check-meti): New pattern function which simply diagnoses any .meti. This relies on the fact that .mono/.onom blocks are matched and consumed by by another rule. All valid .meti lines are consumed as part of these blocks, so any .meti that remain must be outside. * txr.1: Fix numerous occurrences of this.
* doc: really remove @(rcons) pattern operatorKaz Kylheku2021-01-251-49/+1
| | | | | | * txr.1: Fix typo under Range match. Remove the documentation for the nonexistent pattern operator @(rcons ...) that was supposed to be removed before release 249.
* sub-str: compat check now restores 215 behavior.Kaz Kylheku2021-01-251-2/+17
| | | | | | | | | | | * lib.c (sub_str): If compatibility is requested, with a value of 215 or less, then disable the optimization of returning the original string without making a copy. This was found to break the @(freeform) directive. That regression alerts me to the fact that I should have made this subject to compatibility; some user code could be affected. * txr.1: New compat note added, under 215.
* Version 249txr-249Kaz Kylheku2021-01-191-3/+3
| | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise. * txr.vim, tl.vim: Regenerated.
* doc: add back discussion about (rcons ...) pattern.Kaz Kylheku2021-01-241-0/+13
| | | | | | | * txr.1: Add anote that a pattern a..b matches rcons syntax, and add examples. * tests/011/patmatch.tl: new examples from doc added as tests.
* matcher: rescind support for @(rcons ...) patterns.Kaz Kylheku2021-01-241-22/+3
| | | | | | | | | | | | | | | | | | | | | There is no longer any way to write a @(rcons ...) pattern using the range syntax, so there is no point in supporting that operator. The silly syntax @@a..@b which previously worked was actually due to a mistaken requirement in the parser. * share/txr/stdlib/match.tl (compile-range-match): Function moved closer to compile-atom-match, below compile-vec-match. The argument is now a range object containing patterns, so we pull it apart with from and to. (compile-atom-match): Pass range directly to compile-range-match; no need to construct (rcons ...) syntax. * tests/011/patmatch.tl: Add range tests from documentation and a few others. * txr.1: References to @(rcons ...) pattern scrubbed. One wrong #R pattern example corrected.
* parser: fix bad precedence of @ token.Kaz Kylheku2021-01-241-1/+23
| | | | | | | | | | | | | | | | | | | | | | | Whereas @a..@b parses and transforms to (rcons @a @a), @(a)..@(a) goes to @(rcons a @(a)). * parser.l (grammar): Under 248 compatibility or lower, the @ character now produces the OLD_AT token. Otherwise it produces the '@' character, as before. * parser.y (OLD_AT): New token replaces the '@' at the old low precedence position. '@' is now at the highest precedence, together with OLD_DOTDOT. (We don't care about interactions between '@' and OLD_DOTDOT, because OLD_DOTDOT only exists in 185 compatibility, in which '@' is OLD_AT). (meta): The two rules have to be unfortunately duplicated for OLD_AT, since there is no BNF OR operator in Yacc. * txr.1: Compat note added. * lex.yy.c.shipped: Updated. * y.tab.c.shipped, y.tab.h.shipped: Likewise.
* matcher: add support for range objects.Kaz Kylheku2021-01-231-0/+98
| | | | | | | | | | | * share/txr/stdlib/match.tl (compile-atom-match): Handle range type, via transformation to rcons operator and compile-range-mach. (compile-range-match): New function. (compile-match): Hook in compile-range-match for @(rcons). (non-triv-pat-p): Handle range case. * txr.1: Documented.
* doc: fix remove double word.Kaz Kylheku2021-01-231-2/+1
| | | | | * txr.1: Under Structural Pattern Matching, fix "instance instance".
* matcher: add optimized special case to hash pattern.Kaz Kylheku2021-01-221-3/+33
| | | | | | | | | | | | | | | | | | This change causes a key-value pattern like (@a @b) to be treated specially when @a already has a binding from a previous pattern. In this case, it behaves like the trivial key case: the value of @a is looked up to try to find a single value. If @a is not bound, then the exhaustive search takes place, using equal equality. * share/txr/stdlib/match.tl (compile-hash-match): Implement special case. (var-pat-p): New function. * tests/011/patmatch.tl: Existing test case now changes value. New test case added. * txr.1: Documented.
* doc: he -> the fix.Kaz Kylheku2021-01-221-1/+1
| | | | * txr.1: fix typoo under if-match.
* matcher: document hash and some fixes.Kaz Kylheku2021-01-221-3/+122
| | | | | | | | | | | | | * share/txr/stdlib/match.tl (compile-hash-match): Follow rename of is-pattern function to non-triv-pat-p. (is-pattern): Renamed to non-triv-pat-p, to follow terminology in the reference manual. A bug is fixed here: we must recognize cons patterns with operators and variables in the dotted position as non-trivial. * tests/011/patmatch.tl: New hash test case, from doc. * txr.1: Documented hash pattern operator.
* hash: hash-revget now defaults to equal.Kaz Kylheku2021-01-221-1/+10
| | | | | | | | | * hash.c (hash_revget): Default to equal, except in compatibility mode. (hash_keys_of): Also default to equal. This function is too new to bother with compatibility switching. * txr.1: Documented, with compat notes.
* matcher: existing variables in @(all) now backref.Kaz Kylheku2021-01-221-3/+26
| | | | | | | | | | | | | | | | | | This commit fixes the inadequacy that all variables occurring in a pattern under @(all ...) or @(coll ...) are blindly collated into lists, ignoring the fact that they may be previously bound variables that must back-reference and not be colleced into lists (just like in the TXR Pattern language!) * share/txr/stdlib/match.tl (compile-loop-match): Calculate the subset of variables in the pattern that have been freshly bound. Only generate the collection gensyms for those variables and only collect and nreverse those variables. * tests/011/patmatch.tl: Some test cases that backreference into an @(all). * txr.1: Documented.
* doc: fix wrong year in document date.Kaz Kylheku2021-01-211-1/+1
| | | | * txr.1: 2020 -> 2021.
* matcher: new @(coll) operator.Kaz Kylheku2021-01-211-1/+29
| | | | | | | | | | | | | * share/txr/stdlib/match.tl (compile-loop-match): Implement coll semantics. coll fails if it collects nothing, which uses common logic with all*. We just have to move the flipping of the loop-iterated-var into the match, and not do it unconditionally for every iteration. (compile-match): Hook in the coll operator. * tests/011/patmatch.tl: Test case copied from doc example. * txr.1: Documented.
* matcher: @(some) and @(all) work with sequences.Kaz Kylheku2021-01-211-6/+7
| | | | | | | | | | Relax the restrictions in these operators so they work with sequences rather than specifically lists. * share/txr/stdlib/match.tl (compile-loop-match): Make the necessary adjustments so that abstract iteration is used. * txr.1: Documented.
* doc: document new check in iter-step.Kaz Kylheku2021-01-211-1/+36
| | | | | | * txr.1: Document recently introduced check against crossing over into infinite iteration on the terminator of an improper list.
* matcher: allow variables to back-reference.Kaz Kylheku2021-01-201-0/+23
| | | | | | | | | | | | | | | | | | | | | | | | Multiple occurrences of variables unify using equal. * share/txr/stdlib/match.tl (var-list): New struct type. Used for tracking what variables have been defined. (compile-struct-match, compile-vec-match, compile-atom-match, compile-op-match, compile-cons-structure, compile-require-match, compile-let-match, compile-loop-match, compile-parallel-match, compile-not-match): Take var-match argument and pass it down. (compile-parallel-match): Take var-match argument and pass copies of it down to the compile jobs of the branches, since they do not unify. (compile-var-match, comiple-let-match, compile-op-match): Handle variables carefully: check for variable already being defined and generate a backreference instead of a new binding match. (compile-match): Take optional var-list argument, instantiating the object if it is missing, pass down to all recursive compile unctions. * txr.1: Documented.
* doc: another .code typo.Kaz Kylheku2021-01-201-1/+1
| | | | txr.1: Again under the @(not) operator, .cond instead of .code.
* matcher: bugfix and interface change in @(require).Kaz Kylheku2021-01-201-10/+27
| | | | | | | | | | | | | | * share/txr/stdlib/match.tl (compile-require-match): The bug here is that the condition is placed before the match.test-expr, which is incorrect. The conditions can only be evaluated if match.test-expr has succeeded, because otherwise the variables are not validated to have the correctly matching value. Also, in the documentation, the synax insinuates there can be more than one expression. So let's just make it work: require takes multiple expressions and combines them with an implicit and. * txr.1: Documentation updated.