lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On Wednesday, May 14, 2014 05:24:10 PM Coroutines wrote:
> I know * was chosen for "concatenating patterns" because it closer
> resembles the dot operator, but imo it'd make sense to use + for that.

__mul was chosen because of the precedence. Concatenation should have a higher 
precedence than ordered choice. So a number pattern would look like:

    DIGIT^1 + "0x" * HEXDIGIT^1

That would need parenthesis if the precedence were reversed.

Having __bor for ordered choice would be very slightly convenient because 
__add and __sub right now have equal precedence, so you have to avoid this 
ambiguity:

    LEGAL + CHAR - ILLEGAL

But having to add parenthesis here is only a minor inconvenience that probably 
isn't worth the gray matter to juggle new operators. There's no need for 
unproductive bike-shedding.

-- 
tom <telliamed@whoopdedo.org>