the use of #pointsTo: (Re: Boolean expressions (was: Re: [squeak-dev] Re: Object>>#is:? (was: Re: PackageDependencyTest)))

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

the use of #pointsTo: (Re: Boolean expressions (was: Re: [squeak-dev] Re: Object>>#is:? (was: Re: PackageDependencyTest)))

Igor Stasenko
On 4 March 2010 23:23, Bert Freudenberg <[hidden email]> wrote:

> On 04.03.2010, at 22:21, Stéphane Rollandin wrote:
>>
>>> If you have a lot of protocols you can use the super fast
>>> primitive supported #pointsTo: and have a lot cleaner (and possibly
>>> faster) code:
>>>
>>> is: aSymbol
>>>
>>>      ^#(Morph MySpecializedMorph FooMorph BarMorph) pointsTo: aSymbol
>>>
>>
>>
>> wow. thanks for the pointer, I wasn't aware of this one :)
>>
>> Stef
>
> It's also less readable. If you replace #pointsTo: with #includes: I know right away what it means. If you use this low-level optimization I have to think twice which object points where.
>

Yeah. Just a guess, we can add #identityIncludes: to Array
which will use same primitive as pointsTo:

Btw, i find it surprising that:

Array new pointsTo: Array

answering false.

An instance of class is always points to its class, no?

But its great, since we can use this 'bug/feature' to implement
#identityIncludes:  :)

> - Bert -
>


--
Best regards,
Igor Stasenko AKA sig.

Reply | Threaded
Open this post in threaded view
|

Re: the use of #pointsTo: (Re: Boolean expressions (was: Re: [squeak-dev] Re: Object>>#is:? (was: Re: PackageDependencyTest)))

Michael Haupt-3
Hi Igor,

On Thu, Mar 4, 2010 at 10:43 PM, Igor Stasenko <[hidden email]> wrote:
> Btw, i find it surprising that:
>
> Array new pointsTo: Array
>
> answering false.
>
> An instance of class is always points to its class, no?

doesn't #pointsTo: only take indexable / named fields into account?
The class is encoded in the header, that might well be out of scope.
Also, Array is a special class (fast lookup from 1-word header),
right? So the pointer is even less easy to extract. :-P

I need to go to sleep now. :-)

Best,

Michael

Reply | Threaded
Open this post in threaded view
|

Re: the use of #pointsTo: (Re: Boolean expressions (was: Re: [squeak-dev] Re: Object>>#is:? (was: Re: PackageDependencyTest)))

Igor Stasenko
On 4 March 2010 23:47, Michael Haupt <[hidden email]> wrote:

> Hi Igor,
>
> On Thu, Mar 4, 2010 at 10:43 PM, Igor Stasenko <[hidden email]> wrote:
>> Btw, i find it surprising that:
>>
>> Array new pointsTo: Array
>>
>> answering false.
>>
>> An instance of class is always points to its class, no?
>
> doesn't #pointsTo: only take indexable / named fields into account?
> The class is encoded in the header, that might well be out of scope.
> Also, Array is a special class (fast lookup from 1-word header),
> right? So the pointer is even less easy to extract. :-P
>
> I need to go to sleep now. :-)
>

Well, but when you walking the object graph (and #pointsTo: is
existing exactly for doing that), you need to know all connections
without exceptions.
This is where #pointsTo: lies to us, because obviously, all instances
pointing to their corresponding classes.
Concerning subtleties, like special header format and things like
that: hey, this is a primitive after all, and it quite easy to
get a class object from its instance. Otherwise , how then a message
sending machinery might work without being able to do that? :)

> Best,
>
> Michael
>
>



--
Best regards,
Igor Stasenko AKA sig.

Reply | Threaded
Open this post in threaded view
|

Re: the use of #pointsTo: (Re: Boolean expressions (was: Re: [squeak-dev] Re: Object>>#is:? (was: Re: PackageDependencyTest)))

David T. Lewis
In reply to this post by Igor Stasenko
On Thu, Mar 04, 2010 at 11:43:22PM +0200, Igor Stasenko wrote:
>
> Btw, i find it surprising that:
>
> Array new pointsTo: Array
>
> answering false.
>
> An instance of class is always points to its class, no?

  (Array with: Array) pointsTo: Array ==> true

The "points to" refers to the object pointers in the indexable fields
of an object.

Dave