gvanrossum / patma

Pattern Matching
1.02k stars 64 forks source link

Allow binary +/- for complex numbers? #52

Open brandtbucher opened 4 years ago

brandtbucher commented 4 years ago

We already allow a single unary - for negation of numbers. Should we also allow binary + if the LHS is real and the RHS is imaginary, so patterns like 1+2j are possible?

I think yes.

Tobias-Kohn commented 4 years ago

Yes. I think to recall that we already mentioned somewhere that we need to allow + in complex values, but I cannot find it anymore. + and - should both be legal in order to form numeric literals.

brandtbucher commented 4 years ago

Cool. This will realistically include binary - as well, to allow each of:

gvanrossum commented 4 years ago

Yes, exactly. -- --Guido (mobile)

dmoisset commented 4 years ago

Sorry for reraising this, but are there actual use cases for these? In general equality matching with floats and complex are problematic (and the values you'd likely want liko 0, 1, 1j, do not require binary ops). Removing this could simplify a bit

gvanrossum commented 4 years ago

Not worth the ink.