[swift-evolution] Add unless/if single line syntax

Matthew Johnson matthew at anandabits.com
Sat Dec 12 10:49:01 CST 2015

> The feature implemented in the language. What’s not to like?

Closures don't support non-local control (i.e. returning from the function that calls this unless function).  

If Joe Groff's idea on adding non-local control were adopted that would solve this problem and defining it as a function like this might be acceptable.  

I don't think until is solved as easily but it's utility is also more rare.

That said, I'm not sure there is a good argument against "unless" and "until" being keywords.  The argument seems to be a general desire to keep keyword usage to a minimum.  I agree with that in general but I also think it's good to consider potential reasons a programmer would want to use specific words as an identifier.  

IMO the meaning of these words is specific enough that the value of making them part of the language probably outweighs their utility as identifiers when the language itself implements the obvious meaning.

If we don't see them added to the language I think it would be good to add the functions to the standard library so they are a part of the common vocabulary for all Swift developers.  Of course this is just my humble opinion.


More information about the swift-evolution mailing list