
March 1, 2019
10:33 p.m.
Serhiy Storchaka wrote:
And this opens a non-easy problem: how to create a mapping of the same type?
That's the responsibility of the class implementing the + operator. There doesn't have to be any guarantee that a subclass of it will automatically return an instance of the subclass (many existing types provide no such guarantee, e.g. + on strings), so whatever strategy it uses doesn't have to be part of its public API. -- Greg