Plain GROUP! & Branching: Only Run If Branch Taken?

While no one has really commented on this, I think my mind is made up:

It's more intuitive and useful to NOT run the plain GROUP! when the triggering condition is false.

Mechanically, Ren-C has long been able to make a different choice from historical Redbol here, due to changing the parameter conventions to facilitate literal branching.

...speaking of which, my mind is made up on that, too:

Literal branching is now foundational. I use it all the time, and like it. And it's an even bigger efficiency advantage in stackless, where you can provide a value directly and not require pushing a stack frame.

So the decision is made.

What if You Want the Branch to Run Anyway?

Right now the answer is to use a GET-GROUP!.

>> branchy: func [flag] [either flag '[<a>] '[<b>]]

>> either okay (print "a" branchy okay) (print "b" branchy null)
a
== <a>

>> either true :(print "a" branchy okay) :(print "b" branchy null)
a
b
== <a>

The reason it works is that right now, GET-GROUP! unconditional processing is done by the soft-literal parameter convention. So things like EITHER don't have a choice. They receive a plain GROUP! literally, but a GET-GROUP! will have ran before their code starts.

But I doubt anyone was really clamoring for the ability to run code in groups for branches that aren't taken. If you are deeply affected, feel free to write a long sad essay here. :sob:

1 Like