Remix.run Logo
btown 10 hours ago

There's also the good old use case of "am I dealing with a subclass that overrode the superclass's implementation of the method."

How do you distinguish between a superclass that always returns null/noop, vs. a subclass that happened to return null in this specific case?

Sometimes this is useful/vital for setting expectations to the user what functionality the instance is likely to have.

Now, you could refactor everything to have the superclass's implementation either throw a NotImplementedError, or return a sentinel value... but changing every call site might be a gargantuan task. Similarly, adding static metadata to every subclass might not be feasible. But checking whether the function's (pre-bound) identity is different is a very easy hack!

Ironically, this might indeed be exactly what Apple is doing here, and they're doing it in a tight loop.

1718627440 7 hours ago | parent [-]

Couldn't you use isinstance(), which would not be a hack?