You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Looking for more ways to solve Advent of Code, I found out that at least for Tuples, type extension in the case of addition wants to behave like concatenation, no matter what.
I suppose that is because default __add__ does exist as a language construct and cannot be overwritten, while the given __mul__ does not exist between two tuple types.
At this point I would say this is not a bug, and this is actually the way someone would want it, as it would be chaotic otherwise. I admit though it would only be fun for AoC challenges, and maybe nothing else outside of that.
In the same vein, if we try to extend tuples with a method that does not exist in the (Python) language for any type of other:
Hi again folks,
Looking for more ways to solve Advent of Code, I found out that at least for Tuples, type extension in the case of addition wants to behave like concatenation, no matter what.
For example:
Interestingly ,only the
__mul__
dunder is overloaded:I suppose that is because default
__add__
does exist as a language construct and cannot be overwritten, while the given__mul__
does not exist between two tuple types.At this point I would say this is not a bug, and this is actually the way someone would want it, as it would be chaotic otherwise. I admit though it would only be fun for AoC challenges, and maybe nothing else outside of that.
In the same vein, if we try to extend tuples with a method that does not exist in the (Python) language for any type of
other
:Codon says it cannot type check the program:
Which I guess I could also see it making sense. But is this the way you would want extensions to behave?
I'm interested in how you see this.
Don't take this as an issue, I don't want to keep you busy with stuff like this =)
The text was updated successfully, but these errors were encountered: