[squeak-dev] Re: How about... something completely different?

Igor Stasenko siguctua at gmail.com
Thu Dec 10 01:00:33 UTC 2009


2009/12/9 Eliot Miranda <eliot.miranda at gmail.com>:
>
>
> On Wed, Dec 9, 2009 at 10:36 AM, Igor Stasenko <siguctua at gmail.com> wrote:
>>
>> 2009/12/9 Eliot Miranda <eliot.miranda at gmail.com>:
>> >
>> >
>> > On Wed, Dec 9, 2009 at 9:15 AM, Colin Putney <cputney at wiresong.ca>
>> > wrote:
>> >>
>> >> On 8-Dec-09, at 11:02 PM, Igor Stasenko wrote:
>> >>
>> >>> In this respect, interesting, how to avoid a pitfal of circular
>> >>> delegation.
>> >>>
>> >>> x -> y -> x
>> >>>
>> >>> if i send a message to x, and got DNU, it is automatically delegated
>> >>> to
>> >>> y,
>> >>> but in same way as x could delegate to y, y could delegate to another
>> >>> object , and finally some of them
>> >>> in delegation chain could delegate back to x. Circle is closed, and VM
>> >>> will loop forever trying to lookup a method not implemented in any of
>> >>> objects in such delegation chain.
>> >>
>> >> Yup, that's certainly a possibility. The only remedy is "don't do
>> >> that."
>> >> Consider it a bug, in the same way that we currently consider infinite
>> >> recursion a bug.
>> >
>> > and if the concern is a loop in the VM's lookup then all it has to do is
>> > remember the object or class it started the lookup in and abort (go
>> > straight
>> > to sending DNU) if it meets the same one again.
>>
>> Care to add it to Cog as a precaution against future hacks? :)
>
> Good suggestion.  <scottish>Now sends are faster this kind of check is much
> cheaper</scottish>

well, it is costly..

Consider a following:
a -> b -> c -> .... x -> y -> z -> x

so, you will have a loop not poining back to initial lookup class, but
to one in the chain,
which means that every time you going to superclass for lookup, you
need to check it against match will all elements in current lookup
chain.
I think it would be cheaper to prevent such chains be created (by
validating the inheritance once one of the class created, or once
superclass of particular class going to be set).
But the downside of such solution , that its image-based, because in
VM you can't really tell whether particular ivar update will affect
the lookup mechanism or not.

>>
>> >>
>> >> Colin
>> >>
>> >
>> >
>> >
>> >
>> >
>>
>>
>>
>> --
>> Best regards,
>> Igor Stasenko AKA sig.
>>
>
>
>
>
>



-- 
Best regards,
Igor Stasenko AKA sig.



More information about the Squeak-dev mailing list