3 ms·
> Nope. In is_subtype [...] Oh, ok. So it does look a bit broken then :) > Also, could you point me to the Nim feature? That follows from the fact that `some
by klibertp 12y ago
> Nope. In is_subtype [...]
Oh, ok. So it does look a bit broken then :)
> Also, could you point me to the Nim feature?
That follows from the fact that `something.method()` is just a syntactic sugar for `method(something)` and that you can write methods for any type anywhere. The example I specifically had in mind was strutils module, which extends a string type with many useful methods.
Now that I think about it I'm not sure how Nim would handle two methods of the same name for the same type defined in different places. I think it would refuse to compile such code? But that's a guess only, I'd need to check.
EDIT: oh, and I see you complained about redefinition specifically, not about the ability to extend classes in general. Sorry, I somehow missed it.