Oldes / Rebol-wishes

Repository for keeping Rebol related wishes out of issues
0 stars 0 forks source link

Make PARSE's IF an arity-2 operation, instead of arity-1 #54

Open Siskin-Bot opened 4 years ago

Siskin-Bot commented 4 years ago

Submitted by: Hostilefork

The current implementation of IF considers it to be a standalone, arity-1 operation, which either allows you to keep processing or fail:

>> parse "" [if (true)]
== true

>> parse "" [if (false)]
== false

This is quite counter-intuitive, and as a pattern is not extensible to allow for things like EITHER. It would line up better with the expectations of users and the behaviors of the language in general if it were arity-2, as most would expect...and if it failed, it simply did not contribute the corresponding rule.

 >> parse "ac" ["a" if (false) ["b"] "c"]
 true

 >> parse "abc" ["a" if (true) ["b"] "c"]
 true

If coupled with an EITHER construct, then this could use a single condition to trigger failure or not, e.g.

>> parse "abc" ["a" either (condition) ["b"] [reject] "c"]

Imported from: https://github.com/rebol/rebol-issues/issues/2271

Comments:


Hostilefork added the Type.wish on Apr 16, 2017


Hostilefork commented on May 2, 2017:

Note this Red user faced the exact same confusion: https://gitter.im/red/red/welcome?at=59080fc808c00c092ad567aa


IngoHohmann commented on Sep 16, 2017:

I like the arity-2 version a lot better.