Re:Wren is a small, fast, class-based concurrent scripting l...
by geysersam on Monday August 29, 2022 @12:48AM
(#32634898)
I think he meant that for Python operators, the method can be dispatched based on the first or the second argument.
[ Parent
| on HN ]
Re:Wren is a small, fast, class-based concurrent scripting l...
by csande17 on Monday August 29, 2022 @03:12AM
(#32635491)
Yes, this is a special case that Python implements for binary operators. When evaluating "a + b", if a.__add__(b) doesn't work, it'll try b.__radd__(a). See https://docs.python.org/3/reference/datamodel.html#object.__...
Re:Wren is a small, fast, class-based concurrent scripting l...
by pansa2 on Monday August 29, 2022 @03:36AM
(#32635599)
Yeah - `__add__` then `__radd__` isn't exactly double dispatch, but it's close. (There are corner cases involving inheritance where double-dispatch will work correctly but Python's approach will fail to pick the most-specific method.)
Re:Wren is a small, fast, class-based concurrent scripting l...
by munificent on Monday August 29, 2022 @12:06PM
(#32639853)
Yes, this is what I was referring to.