What Should BLANK! in UPARSE Do?

It's always good to look at history first. So let's compare and contrast #[none] vs. empty block in old Redbols.

In Rebol2 and R3-Alpha, both are no-ops. The input type doesn't matter.

r2/r3>> parse {ab} [[] "a" [] "b" []]
== true

r2/r3>> parse {ab} [#[none] "a" #[none] "b" #[none]]
== true

r2/r3>> parse [a b] [[] 'a [] 'b []]
== true

r2/r3>> parse [a b] [#[none] 'a #[none] 'b #[none]]
== true

In Red, #[none]s are expected to be literal. However, you don't get an error on string inputs...just a failure.

red>> parse {ab} [[] "a" [] "b" []]
== true

red>> parse {ab} [#[none] "a" #[none] "b" #[none]]
== false

red>> parse [a b] [[] 'a [] 'b []]
== true

red>> parse [a b] [#[none] 'a #[none] 'b #[none]]
== false

red>> parse [#[none] a #[none] b #[none]] [#[none] 'a #[none] 'b #[none]]
== true

I Think No-Op Is the Superior Choice for BLANK! (NONE!)

Ren-C's philosophy surrounding blank as "reified nothing" is that it is there to signal opting-out.

It's raison d'etre is being falsey, and easy to test for its nothing-ish state...easily convertible to and from NULL. (NULL rules are errors, as they should be).

The idea of being able to look for literal values is being explored other ways, the @ was one proposal (though this is going back and forth).

  >> var: _

  >> uparse [_ _ _] [some @var]
  == #[true]

But a blank rule is more effectively a no-op, IMO.

(For a time it had been considered that it could be a way of matching ANY-VALUE!, but that is now done more clearly with the <any> tag combinator, which is working out splendidly.)

What Should a BLANK! Rule's Synthesized Product Be?

When it comes to empty blocks, I'm pretty solidly sold that the answer is a ~none~ isotope:

>> rule: []

>> did uparse {ab} ["a" x: rule "b"]
== #[true]

>> x
** Script Error: x is ~none~ isotope

There's a deeply interlocked set of justifications for that, which (I hope) aren't going to need rethinking.

But with BLANK! rules it's not so obvious:

>> rule: _

>> did uparse {ab} ["a" x: rule "b"]
== #[true]

>> x
== ???

I'm skeptical of vaporization, e.g. (x = "b") It seems that would be useful only in the most rare of situations, and 99% of the time it would surprise the caller.

The philosophy of "blank in, null out" suggests NULL. That seems useful. (Implementation of this would actually return a null isotope, such that the rule could still look successful while handing back that result!)

I think that gives a pretty interesting shape to things. Because this is new, I'll have to look for applications of it...but I'm pretty sure they will show up. If I see any, I'll make a note of them here.

1 Like