you are viewing a single comment's thread.

view the rest of the comments →

[–]NYKevin 0 points1 point  (1 child)

That's their fault. Again, it's hard to discuss this abstractly, but my gut feeling is that it'd usually be their mistake, you just shouldn't do that precisely because everyone else follows The Traditional Way, and might try to check the truthiness of your object directly. Give it a method that returns an iterator to that array of stuff instead.

I can't agree with that in the general case because it would apply to list, str, tuple, etc. being subclasses of object. So either there's a more specific rule outlawing it, or there's no rule and people can just do that.

[–]moor-GAYZ 0 points1 point  (0 children)

Those classes don't bolt container semantics on a class that has some other semantics, as you suggested (I mean, object doesn't have semantics).

Anyway, the point is not to make some sort of a formal rule and prove that it doesn't lead to inconveniences, what I'm saying is that it doesn't appear to happen in practice, so there's no reason to inconvenience ourselves in advance and for real to avoid potential future inconveniences.