[vwnc] Set equality testing...

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

[vwnc] Set equality testing...

Rick Flower
Hi all..

Just a quick question.. I ran across a difference between Squeak and VW
last night that had me wondering, and while I could extend the Set class to
cover it, I'm not sure it wouldn't have ramifications with other areas within
VW that use the Set class..

Anyway, the issue revolves around the use of #= on a pair of Sets.. In
Squeak,
the pair of sets are considered equal if that have the same contents but not
necessarily if they're the same underlying objects.  In VW the Set class
defers the comparison to the Object base class which maps #= to #== so in
this case the sets are only equal IF they both are the exact same object..

Anyway, not sure if there's some underlying reasoning behind this but thought
I'd ask regardless.. TIA!

-- Rick


_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Reply | Threaded
Open this post in threaded view
|

Re: [vwnc] Set equality testing...

Boris Popov, DeepCove Labs (SNN)
Rick,

There's #elementsEqual: in Com-Extensions that'll do the trick for you,

Collection>>elementsEqual: otherCollection
 "Answer <true> if the elements of the receiver
  and the <otherCollection> are equal."

 self size = otherCollection size ifFalse: [^false].
 self do: [:each | (otherCollection includes: each)
                                ifFalse: [^false]].
 ^true

Cheers,

-Boris

--
+1.604.689.0322
DeepCove Labs Ltd.
4th floor 595 Howe Street
Vancouver, Canada V6C 2T5
http://tinyurl.com/r7uw4

[hidden email]

CONFIDENTIALITY NOTICE

This email is intended only for the persons named in the message header.
Unless otherwise indicated, it contains information that is private and
confidential. If you have received it in error, please notify the sender
and delete the entire message including any attachments.

Thank you.

-----Original Message-----
From: [hidden email] [mailto:[hidden email]] On
Behalf Of Rick Flower
Sent: September 23, 2008 9:43 AM
To: [hidden email]
Subject: [vwnc] Set equality testing...

Hi all..

Just a quick question.. I ran across a difference between Squeak and VW
last night that had me wondering, and while I could extend the Set class
to
cover it, I'm not sure it wouldn't have ramifications with other areas
within
VW that use the Set class..

Anyway, the issue revolves around the use of #= on a pair of Sets.. In
Squeak,
the pair of sets are considered equal if that have the same contents but
not
necessarily if they're the same underlying objects.  In VW the Set class
defers the comparison to the Object base class which maps #= to #== so
in
this case the sets are only equal IF they both are the exact same
object..

Anyway, not sure if there's some underlying reasoning behind this but
thought
I'd ask regardless.. TIA!

-- Rick


_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc

_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Reply | Threaded
Open this post in threaded view
|

Re: [vwnc] Set equality testing...

Eliot Miranda-2
In reply to this post by Rick Flower


On Tue, Sep 23, 2008 at 9:42 AM, Rick Flower <[hidden email]> wrote:
Hi all..

Just a quick question.. I ran across a difference between Squeak and VW
last night that had me wondering, and while I could extend the Set class to
cover it, I'm not sure it wouldn't have ramifications with other areas within
VW that use the Set class..

Anyway, the issue revolves around the use of #= on a pair of Sets.. In
Squeak,
the pair of sets are considered equal if that have the same contents but not
necessarily if they're the same underlying objects.  In VW the Set class
defers the comparison to the Object base class which maps #= to #== so in
this case the sets are only equal IF they both are the exact same object..

Anyway, not sure if there's some underlying reasoning behind this but thought
I'd ask regardless.. TIA!

VW let's the perfect be the enemy of the good.  Because a Set could contain itself (or the two sets being compared could include each other) there's potential for the comparison to never terminate, or to be slow when complicated by adding a visited set to prevent recursion.

Squeak follows the 95% rule and assumes that most of the time when you compare sets they're not recursive and so the simple implementation will suffice.

I think Squeak's approach is far superior.  There's nothing to prevent adding a more sophisticated comparison function that handles recursion, and the naive #= implementation is useful and works most of the time.  The 95% rule was used when Smalltalk was being implemented in the first place.  IMO, it is still a good maxim.

Eliot


-- Rick


_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc


_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Reply | Threaded
Open this post in threaded view
|

Re: [vwnc] Set equality testing...

Andres Valloud-3
In reply to this post by Rick Flower
Hello,
> In VW the Set class
> defers the comparison to the Object base class which maps #= to #== so in
> this case the sets are only equal IF they both are the exact same object..
>  

Not anymore in 7.6... now Sets are equal if they are of the same size
and if they have the same (recursively checked) contents.  Both #= and
#hash tend to assume the receivers are not recursive.

Andres.
_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Reply | Threaded
Open this post in threaded view
|

Re: [vwnc] Set equality testing...

Rick Flower
On Tue, September 23, 2008 11:13 am, Andres Valloud wrote:

> Hello,
>> In VW the Set class
>> defers the comparison to the Object base class which maps #= to #== so
>> in
>> this case the sets are only equal IF they both are the exact same
>> object..
>>
>
> Not anymore in 7.6... now Sets are equal if they are of the same size
> and if they have the same (recursively checked) contents.  Both #= and
> #hash tend to assume the receivers are not recursive.

Hmm.. I am using 7.6 and stepped into the code for #= and it was down in
the Object class which in turn invoked #== (also in the Object class).
Perhaps I've loaded something which removed the stock functionality?
I'll take a look when I get home..

Thanks everyone for the suggestions/info!

_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Reply | Threaded
Open this post in threaded view
|

Re: [vwnc] Set equality testing...

Boris Popov, DeepCove Labs (SNN)
Affirmative,

Set new = Set new  ->  false

This is in 7.6,

Andres?

-Boris

--
+1.604.689.0322
DeepCove Labs Ltd.
4th floor 595 Howe Street
Vancouver, Canada V6C 2T5
http://tinyurl.com/r7uw4

[hidden email]

CONFIDENTIALITY NOTICE

This email is intended only for the persons named in the message header.
Unless otherwise indicated, it contains information that is private and
confidential. If you have received it in error, please notify the sender
and delete the entire message including any attachments.

Thank you.

-----Original Message-----
From: [hidden email] [mailto:[hidden email]] On
Behalf Of Rick Flower
Sent: September 23, 2008 11:53 AM
To: Andres Valloud
Cc: [hidden email]
Subject: Re: [vwnc] Set equality testing...

On Tue, September 23, 2008 11:13 am, Andres Valloud wrote:
> Hello,
>> In VW the Set class
>> defers the comparison to the Object base class which maps #= to #==
so
>> in
>> this case the sets are only equal IF they both are the exact same
>> object..
>>
>
> Not anymore in 7.6... now Sets are equal if they are of the same size
> and if they have the same (recursively checked) contents.  Both #= and
> #hash tend to assume the receivers are not recursive.

Hmm.. I am using 7.6 and stepped into the code for #= and it was down in
the Object class which in turn invoked #== (also in the Object class).
Perhaps I've loaded something which removed the stock functionality?
I'll take a look when I get home..

Thanks everyone for the suggestions/info!

_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc

_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Reply | Threaded
Open this post in threaded view
|

Re: [vwnc] Set equality testing...

Eliot Miranda-2
In reply to this post by Andres Valloud-3


On Tue, Sep 23, 2008 at 11:13 AM, Andres Valloud <[hidden email]> wrote:
Hello,
> In VW the Set class
> defers the comparison to the Object base class which maps #= to #== so in
> this case the sets are only equal IF they both are the exact same object..
>

Not anymore in 7.6... now Sets are equal if they are of the same size
and if they have the same (recursively checked) contents.  Both #= and
#hash tend to assume the receivers are not recursive.

Good news!
 


Andres.
_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc


_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Reply | Threaded
Open this post in threaded view
|

Re: [vwnc] Set equality testing...

Boris Popov, DeepCove Labs (SNN)
In reply to this post by Boris Popov, DeepCove Labs (SNN)
Set lookUpSelector: #= ifAbsent: [nil] -> CompiledMethod Object>>=

-Boris

--
+1.604.689.0322
DeepCove Labs Ltd.
4th floor 595 Howe Street
Vancouver, Canada V6C 2T5
http://tinyurl.com/r7uw4

[hidden email]

CONFIDENTIALITY NOTICE

This email is intended only for the persons named in the message header.
Unless otherwise indicated, it contains information that is private and
confidential. If you have received it in error, please notify the sender
and delete the entire message including any attachments.

Thank you.

-----Original Message-----
From: [hidden email] [mailto:[hidden email]] On
Behalf Of Boris Popov
Sent: September 23, 2008 11:59 AM
To: [hidden email]; Andres Valloud
Cc: [hidden email]
Subject: Re: [vwnc] Set equality testing...

Affirmative,

Set new = Set new  ->  false

This is in 7.6,

Andres?

-Boris

--
+1.604.689.0322
DeepCove Labs Ltd.
4th floor 595 Howe Street
Vancouver, Canada V6C 2T5
http://tinyurl.com/r7uw4

[hidden email]

CONFIDENTIALITY NOTICE

This email is intended only for the persons named in the message header.
Unless otherwise indicated, it contains information that is private and
confidential. If you have received it in error, please notify the sender
and delete the entire message including any attachments.

Thank you.

-----Original Message-----
From: [hidden email] [mailto:[hidden email]] On
Behalf Of Rick Flower
Sent: September 23, 2008 11:53 AM
To: Andres Valloud
Cc: [hidden email]
Subject: Re: [vwnc] Set equality testing...

On Tue, September 23, 2008 11:13 am, Andres Valloud wrote:
> Hello,
>> In VW the Set class
>> defers the comparison to the Object base class which maps #= to #==
so
>> in
>> this case the sets are only equal IF they both are the exact same
>> object..
>>
>
> Not anymore in 7.6... now Sets are equal if they are of the same size
> and if they have the same (recursively checked) contents.  Both #= and
> #hash tend to assume the receivers are not recursive.

Hmm.. I am using 7.6 and stepped into the code for #= and it was down in
the Object class which in turn invoked #== (also in the Object class).
Perhaps I've loaded something which removed the stock functionality?
I'll take a look when I get home..

Thanks everyone for the suggestions/info!

_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc

_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc

_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Reply | Threaded
Open this post in threaded view
|

Re: [vwnc] Set equality testing...

Andres Valloud-3
In reply to this post by Boris Popov, DeepCove Labs (SNN)
Oh, doh... it's in for 7.7, but I thought it was out there already in
7.6.  Sorry!

Andres.


Boris Popov wrote:

> Affirmative,
>
> Set new = Set new  ->  false
>
> This is in 7.6,
>
> Andres?
>
> -Boris
>
>  

_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc