summaryrefslogtreecommitdiffstats
path: root/txr.1
Commit message (Collapse)AuthorAgeFilesLines
...
* list-builder: methods return object.Kaz Kylheku2021-02-261-8/+23
| | | | | | | | | | | | The list-builder methods, other than del, del* and get, now return the object instead of nil. * share/txr/stdlib/build.tl (list-builder (add, add*, pend, pend*, ncon, ncon*): Return the object, self. (list-builder-flets): Do not return the object out of the local functions which invoke the above methods. * txr.1: Documented.
* doc: fix misleading @(call @'foo).Kaz Kylheku2021-02-171-9/+4
| | | | | | * txr.1: The documentation wrongly refers to @(call @'foo) which hasn't worked that way since version 144. The first argument is a Lisp expression.
* doc: improve quote operator.Kaz Kylheku2021-02-171-8/+28
| | | | * txr.1: Improved description of quote operator.
* doc: wording improvements in pattern matching intro.Kaz Kylheku2021-02-121-9/+20
|
* compiler/vm: more compact frame size for closures.Kaz Kylheku2021-02-111-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Closures do not share t-registers with surrounding code; they do not store a value into such a register that code outside the closure would read and vice versa. When compiling closures, we can can temporarily reset the compiler's t-register allocator machinery to get low t-register values. Then, when executing the closure, we reserve space just for the registers it needs, not based off the containing vm description. Here we make a backwards-incompatible change. The VM close instruction needs an extra parameter indicating the number of t-regisers. This is stored into the closure and used for allocating the frame when it is dispatched. * parser.c (read_file_common): We read nothing but version 6 tlo files now. * share/txr/stdlib/asm.tl (op-close asm): Parse new ntreg argument from close syntax, and put it out as an extra word. Here is where we pay for this improvement in extra code size. (op-close dis): Extract the new argument from the machine code and add it to the disassembled format. * share/txr/stdlib/compiler.tl (compile-in-toplevel): Save and restore the t-reg discards list also. Don't bother with a gensym for the compiler; the argument is always a symbol, which we can use unhygienically like in with-var-spy. (compile-with-fresh-tregs): New macro based on compile-in-toplevel: almost the same but doesn't reset the level. (comp-lambda-impl): Use compile-with-fresh-tregs to compile the entire closure with a minimized register set. Place the treg-cntr into the closure instruction to indicate the number of registers the closure requires. * vm.c (struct vm): New member, nreg. (vm_make_closure): New parameter, nreg, stored into the closure. (vm_close): Extract a third opcode word, and pull the nreg value from the bottom half. Pass this to vm_make_closure. (vm_execute_closure, vm_funcall_common): Calculate frame size based on the closur's nreg rather than the VM description's. * txr.1: Document that the upcoming version 252 produces version 6.0 object files and only loads version 6.
* doc: fix broken my-cond example.Kaz Kylheku2021-02-091-4/+4
| | | | | * txr.1: Replace obsolete @[...] predicate notation in the my-cond example with working code.
* doc: fix lambda-mach typo.Kaz Kylheku2021-02-091-1/+1
|
* doc: fix match-case intro sentence.Kaz Kylheku2021-02-091-1/+1
| | | | * txr.1: "the match-case macro", not "the match-case".
* doc: explain dot position of variable in predicate.Kaz Kylheku2021-02-091-0/+23
| | | | | | * txr.1: Explain that the dot position of a variable in a predicate pattern corresponds to the usual application syntax. Add an example of this from the test case file.
* 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.