[Pharo-project] Interval>>basicAt: fails
Try the following (1) (1 to: 10) at: 2 returns 2 then (2) (1 to: 10) basicAt: 2 raises an exception It is surprising. Problem is that Interval redefines at: but in (2), the lookup retrieves Object>>basicAt: which only works for indexable objects (which an interval is not). So Interval should also redefine basicAt: ? -- Simon
Simon Denier wrote:
Try the following (1) (1 to: 10) at: 2 returns 2
then (2) (1 to: 10) basicAt: 2 raises an exception
It is surprising.
Problem is that Interval redefines at: but in (2), the lookup retrieves Object>>basicAt: which only works for indexable objects (which an interval is not).
So Interval should also redefine basicAt: ?
I do not find this surprising. The #basic* methods are intended to be fundamental, never overridden, and to reveal the internal structure of an object. This breaks encapsulation, but you need *some* messages that do that or you can't write debugging tools such as inspectors. So it sounds to me like it's correct as is. Regards, -Martin
Why would you want to call #basicAt:? As the comment in Object>>basicAt: says, this works only for indexable objects, and Interval is not indexable. So this looks like the expected behavior to me. Cheers, Adrian On Nov 21, 2009, at 21:32 , Simon Denier wrote:
Try the following (1) (1 to: 10) at: 2 returns 2
then (2) (1 to: 10) basicAt: 2 raises an exception
It is surprising.
Problem is that Interval redefines at: but in (2), the lookup retrieves Object>>basicAt: which only works for indexable objects (which an interval is not).
So Interval should also redefine basicAt: ?
-- Simon
_______________________________________________ Pharo-project mailing list Pharo-project@lists.gforge.inria.fr http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
OK, this sounds like an education/learning the tricks problem then :) On 21 nov. 2009, at 17:37, Adrian Lienhard wrote:
Why would you want to call #basicAt:?
As the comment in Object>>basicAt: says, this works only for indexable objects, and Interval is not indexable. So this looks like the expected behavior to me.
Cheers, Adrian
On Nov 21, 2009, at 21:32 , Simon Denier wrote:
Try the following (1) (1 to: 10) at: 2 returns 2
then (2) (1 to: 10) basicAt: 2 raises an exception
It is surprising.
Problem is that Interval redefines at: but in (2), the lookup retrieves Object>>basicAt: which only works for indexable objects (which an interval is not).
So Interval should also redefine basicAt: ?
-- Simon
_______________________________________________ Pharo-project mailing list Pharo-project@lists.gforge.inria.fr http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
_______________________________________________ Pharo-project mailing list Pharo-project@lists.gforge.inria.fr http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
-- Simon
participants (3)
-
Adrian Lienhard -
Martin McClure -
Simon Denier