Dialecting Quasiforms In PARSE

The first thought I had about what quasiforms might be useful for would be to match a series of items as a splice:

>> parse [a b c d] ['a ['b 'c 'd]]
== d

>> parse [a b c d] ['a ~(b c d)~]
== ~(b c d)~  ; anti

That's like the behavior of match literally of a splice:

>> parse [a b c d] ['a @(spread [b c d])]
== ~(b c d)~  ; anti

But on the downside... if the behavior of quasiforms is taken to mean "match content", since antiforms can't occur in blocks then quasi-group would be the only useful antiform. All the rest would be useless or have to come up with some custom definition.

Another possibility would be if quasiforms synthesized the antiform without matching anything:

>> parse [a] ['a ~(b c d)~]
== ~(b c d)~  ; anti

 >> parse "aaa" [let x: ~null~ some "a" (x)]
 == ~null~  ; anti

 >> [x y]: parse "aaa" [some "a" ~['a '10]~ | some "b" ~['b '20]~]
 == a

 >> y
 == 10

But that's just a synonym for using GROUP! and code to synthesize the value (e.g. let x: (~null~) or let x: (null) instead of let x: ~null~). The only advantage here is that it's faster (no execution required, just drop the quote byte from QUASIFORM_2 down to ANTIFORM_0).

(I've already contemplated the idea of x: ~null~ vs. x: null as something which could be done in code that you're trying to micro-optimize.)

But Dialecting Is Supposed To Be Powerful...

Rote production of antiforms seems weak compared to dreaming up useful constructs.

e.g. quasi-TRIPWIRE could raise an error with a string (possibly even an interpolated one!)

>> letter: #b

>> parse "aaa" [some letter | ~<Expected all (letter)>~]
** Error: Expected all b

That's quite compelling, and supports the argument that maybe customizing the meanings is worth it. For instance ~[...]~ could actually run PACK vs. being the literal pack.

>> [a b]: parse [10 20] [let x: integer! let y: integer! ~[x y]~]
== 10

>> a
== 10

>> b
== 20

"But that's not what the evaluator does with QUASI-BLOCK!" you might say. No, but it's inside PARSE, nothing is doing what the evaluator does. That's the whole premise of the language!

A similar premise could apply to the splicing...and it doesn't even have to return a splice!

>> middle-letter: 'c

>> parse [a b c d] ['a ~('b middle-letter 'd)~]
== [b c d]

All QUASI-words are available, while not all antiforms of words are legal. Since parse is using quasiforms then it means every word is possible. It could represent an error ID, or something else... maybe shorthands for things like accepting and rejecting?

>> parse "aaabbb" [some "a" ~accept~]  ; synonym for [accept <input>]
== "aaabbb"

Ok, I really like this idea, of clever applications, vs. simply synthesizing antiforms and not matching! It's clearly much neater.

Ren-C has given Rebol quantum leaps in expressivity.

:frog: :atom_symbol:

1 Like

Wicked!!! Love to see the renewed energy and focus yielding big results!