Proposing AND, OR as alternative syntax for the &&, || logical operators?

I performed a cursory search of past Swift proposals, and I did not find any that proposed that Swift recognize and and or as alternative tokens for the current logical && and || operators. So, I am posting here to try and find out for certain whether this Swift language enhancement has in fact ever been proposed (and, presumably, rejected).

The purpose of this enhancement would be to provide Swift with a more human-readable, "script-like" syntax - which I believe aligns well with Swift's longstanding goals as a language. This addition would also make Swift syntax more consistent with other programming languages (including C++, which supports both syntaxes) - and thereby better accommodate new Swift programmers (who may have experience in other languages, such as Python) and help make them feel more at home in Swift.

I am more interested in confirming that this would be a novel proposal, rather than discussing its merits at this point in its evolution. Although I am not opposed to having such a discussion in an appropriate forum.

Greg

13 Likes

No, that would be a too major change. Currently, the sets of characters that can be used in operators and identifiers do not overlap.


The obvious alternatives
  • you custom standalone functions, example:
    not(and(or(a, b), or(c, d)))
  • ditto but methods on Bool, for example:
    a.or(b).and(c.or(d)).not

Those would be equivalents of:

    !((a || b) && (c || d))