markm 01/12/22 23:49:31 Added: doc/elang/quasi index.html like-ellipses.html Log: start on separate doc section on quasis Revision Changes Path 1.1 e/doc/elang/quasi/index.html Index: index.html =================================================================== <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN"> <!--last modified on Saturday, October 03, 1998 04:19 PM -->Title Bar Title
|
Like regular expressions, our quasi-literal term-tree patterns and expressions have quantifiers. These quanitifiers annotate the pattern or expression to its left.
These quantifiers normally just annotate patterns. Why do we also apply them to expressions? In order to incorporate the expressiveness of Scheme's "..." notation. This is best explained by transposing Scheme's example into term trees: The text in the boxes below is from the Scheme FAQ.
Likewise for term trees of course. For us, the corresponding example pattern might be term`[[@a, @c*], [@b, @d*], [@e*]*]` or, as an expression, with '$'s rather than '@'s. Note that
the square brackes are just syntactic sugar for a term with " term`tuple(tuple(@a, @c*), tuple(@b, @d*), tuple(@e*)*)`
When these variables are different sizes, since this is a likely indicator of a bug, and because its easily repaired when it's intentional, E considers this case to be an error. ? def term`foo([@a*],[@b*])` := term`foo([1,2],[3,4,5])` # value: term`foo([1, 2], # [3, 4, 5])` ? a # value: [term`1`, term`2`] ? b # value: [term`3`, term`4`, term`5`] ? term`[[$a,$b]*]` # problem: Failed: Inconsistent shape: 2 vs 3 So let's shorten ? def b2 := b(0,2) # value: [term`3`, term`4`] ? term`[[$a,$b2]*]` # value: term`[[1, 3], # [2, 4]]` But when the variable is too flat, so to speak (insufficient dimensions or rank), E takes the same permissive attitute as shown by the following Scheme example.
? def term`foo([@a*], [@b*]*)` := term`foo([1,2], [3,4], [5,6,7])` # value: term`foo([1, 2], # [3, 4], # [5, 6, 7])` ? a # value: [term`1`, term`2`] ? b # value: [[term`3`, term`4`], [term`5`, term`6`, term`7`]] ? term`[[[$a,$b]*]*]` # value: term`[[[1, 3], # [1, 4]], # [[2, 5], # [2, 6], # [2, 7]]]` Since literal data is repeated as many times as necessary, variables
that are too flat, like What are some other good examples of the power of Scheme's "..." that we should also use here? AcknowledgementsWho should we acknowledge for Scheme's "..." system? Matthias Radestock, the editor of the FAQ we quote from above. Dean Tribble, who suggested incorporating the power of Scheme's "..." into the quasi-literal handing of Term trees. |
|||||||||||||
|
|
|||||||||||||