SPREAD in PARSE: Isotopic Matching

Remember that the @var rule will match the contents of variables literally, vs. running them as a rule:

>> var: [some rule]
== [some rule]

>> parse [[some rule] [some rule]] [some @var]
== [some rule]

You can evaluate an expression to literally match, too:

>> parse [[some rule] [some rule]] [some @(reverse copy [rule some])]
== [some rule]

Now there's a powerful new twist: You can match in a spliced fashion, using an isotopic block!

>> var: [some rule]

>> parse [some rule some rule] [some @(spread var)]
== ~[some rule]~  ; isotope

And you can synthesize a product that may be a splice or not!!!

>> append [a b c] parse [1 2 3] [block! | spread across some integer!]
== [a b c 1 2 3]

>> append [a b c] parse [[x y z]] [block! | spread across some integer!]
== [a b c [x y z]]

Encoding the splicing intent on the value is clearly the way to go. Seems obvious now, but hindsight is 20/20.

3 Likes