[Newbies] Character allInstances size=0 for 5.3 latest

K K Subbu kksubbu.ml at gmail.com
Tue Mar 3 01:53:38 UTC 2020


On 02/03/20 11:14 PM, Vaidotas Didžbalis wrote:
> Your second definition for the term Instance, I believe, is not good, -- 
> where is it taken from? Here, as a user I care about interface and 
> correct results, not about performance.

Behavior>>allInstances method iterates through objects *in memory* using 
someInstance and nextInstance primitives. Immediate objects are 
cardinals and not ordinals, so nextInstance does not apply to them.

See the methods primitiveSomeInstance and primitiveNextInstance in VMMaker.

When primitiveSomeInstance returns nil, it means there are no instances 
*in memory*.

> The name of a method is essential in order to understand what the system 
> does. Now, v5.3 states that there are 0 instances of the Character in 
> it. This is not true.

It is not true only by your definition of instance, but not as per VM 
interpretation. The VM implementor has opted to exclude immediate 
objects from consideration for pragmatic reasons.

Semantically the arithmetic operation a+b may be defined for all a, b 
but pragmatics can limit this to modulo arithmetic.

> We could rename the method, register a bug for the 
> X release, or why not signal an exception  (#NotImplemented)? Because as 
> it stands now, class Character does not know how to respond to a 
> question about its instances but instead it claims to know and gives the 
> incorrect answer.
It is possible to iterate through all oops to find instances of 
Characters to conform to your definition. This would be an expensive 
operation. But what pragmatic purpose will be served? The juice has to 
be worth the squeeze.

Regards .. Subbu


More information about the Beginners mailing list