The new concept behind UPARSE rules is that all rules (besides a few invisibles like ELIDE) give back values. Then BLOCK! rules that match evaluate to the last rule result.
The catch is that we don't want rules commonly used for matching and seeking to synthesize complicated results. What they give back should be cheap...either something they already have on hand, or an isotope if they can't think of anything useful.
Imagine a BINARY! that has a lot of leading zeros, like maybe a megabyte's worth, and you want to skip that:
parse giant-binary-leading-zeroes [some #{00}, data: copy to end]
It would be annoying if SOME #{00} returned a megabyte-long binary of zeros, that just got discarded. So it has to return something else.
I mentioned that one useful thing that can be returned by a rule like #{00} is the value itself:
>> uparse #{00} [x: #{00}]
>> x
== #{00}
The reason this isn't useless is that it gives you at least information about what match you might have in cases like this:
>> uparse #{00} [x: [#{00} | #{FF}]]
>> x
== #{00}
That could fit into the puzzle of being something helpful to know. What's neat though is that you can override this if you like, just as you would in any other evaluation:
>> uparse #{00} [x: [#{00} (<zero>) | #{FF} (<max>)]]
>> x
== <zero>
So now... what should SOME return? Right now I'm thinking the last match:
>> uparse #{00FF} [x: some [#{00} | #{FF}]]
>> x
== #{FF}
Notice that it is returning the #{FF} from the rule... because it can't return the #{FF} in #{00FF} since generically that series could stretch arbitrarily on past the rule.
However...it would be possible to return information from the input data if it were matching a block input:
>> uparse [#{00} #{FF}] [x: some [#{00} | #{FF}]]
>> x
== #{FF} ; There's a choice of which #{FF} to return
This is a bit of a conundrum. It seems that the more useful thing to capture would be the data from the input, though that would be inconsistent with what we are forced to do when matching string and binary series.
If we went the consistent route, then getting the input value becomes more complex:
>> uparse [#{00} #{FF}] [x: some [ahead #{00} skip | ahead #{FF} skip]]
>> x
== #{FF} ; This would be the #{FF} from the input, not the rule
(There could be an operator that encapsulates the AHEAD RULE SKIP pattern more succinctly.)
Alternatively, there could be an acceptance of the inconsistency: block rules captures an item from input, string and binary rules get the series out of the rule itself. I'm leaning against this, however...I prefer consistent.
Hopefully getting more experience will inform this...I just wanted to mention the issue.