||||(in-hole term term)|
||||... ; literal ellipsis|
A term written (term-sequence ...) constructs a list of the terms constructed by the sequence elements.
A term written ,racket-expression evaluates the racket-expression and substitutes its value into the term at that point.
A term written ,@racket-expression evaluates the racket-expression, which must produce a list. It then splices the contents of the list into the expression at that point in the sequence.
A term written hole produces a hole.
A term written as a literal boolean or a string produces the boolean or the string.
It behaves similarly to quasiquote, except for a few special forms that are recognized (listed below) and that names bound by term-let are implicitly substituted with the values that those names were bound to, expanding ellipses as in-place sublists (in the same manner as syntax-case patterns).
|(term-let ([body '(+ x 1)]|
|[(expr ...) '(+ - (values * /))]|
|[((id ...) ...) '((a) (b) (c d))])|
|(term (let-values ([(id ...) expr] ...) body)))|
|'(let-values ([(a) +]|
|[(c d) (values * /)])|
|(+ x 1))|
It is an error for a term variable to appear in an expression with an ellipsis-depth different from the depth with which it was bound by term-let. It is also an error for two term-let-bound identifiers bound to lists of different lengths to appear together inside an ellipsis.
|(term-let ([tl-pat expr] ...) body)|
Note that each ellipsis should be the literal symbol consisting of three dots (and the ... elsewhere indicates repetition as usual). If tl-pat is an identifier, it matches any value and binds it to the identifier, for use inside term. If it is a list, it matches only if the value being matched is a list value and only if every subpattern recursively matches the corresponding list element. There may be a single ellipsis in any list pattern; if one is present, the pattern before the ellipses may match multiple adjacent elements in the list value (possibly none).
This form is a lower-level form in Redex, and not really designed to be used directly. If you want a let-like form that uses Redex’s full pattern matching facilities, see term-match and term-match/single.
When evaluating a term-match expression, the patterns are compiled in an effort to speed up matching. Using the procedural result multiple times to avoid compiling the patterns multiple times.
Raises an exception recognized by exn:fail:redex? if no clauses match or if one of the clauses matches multiple ways.
When evaluating a term-match/single expression, the patterns are compiled in an effort to speed up matching. Using the procedural result multiple times to avoid compiling the patterns multiple times.
Does not expect the input symbols to be distinct, but does produce variables that are always distinct.