Newsgroups: comp.lang.smalltalk
Path: cantaloupe.srv.cs.cmu.edu!nntp.club.cc.cmu.edu!goldenapple.srv.cs.cmu.edu!das-news2.harvard.edu!fas-news.harvard.edu!newspump.wustl.edu!data.ramona.vix.com!sonysjc!su-news-hub1.bbnplanet.com!cpk-news-hub1.bbnplanet.com!news.bbnplanet.com!newsfeed.nacamar.de!uunet!in2.uu.net!129.33.24.22!fox.almaden.ibm.com!garlic.com!news.scruz.net!cruzio.com!news
From: "James A. (Jim) Sawyer" <jas@cruzio.com>
Subject: Re: = and ==
Content-Type: text/plain; charset=us-ascii
Reply-To: jas@cruzio.com
Sender: news@cruzio.com (System Administrator)
Content-Transfer-Encoding: 7bit
Organization: Cruzio Community Networking System, Santa Cruz, CA
Message-ID: <334D18E2.141C@cruzio.com>
References: <334532E2.10C8@fedex.com> <5ifqr1$ju4$1@grimsel.zurich.ibm.com>
X-Mailer: Mozilla 3.0 (Win16; U)
Mime-Version: 1.0
X-Nntp-Posting-Host: kelp132.cruzio.com
Date: Thu, 10 Apr 1997 16:44:18 GMT
Lines: 74

Paul_Gover@uk.ibm.com@ wrote:
> 
> In <334532E2.10C8@fedex.com>, Yu Chen <ychen@fedex.com> writes:
> 
> >Are the following statements true?
> >1) If object a and b are ==, they must be =.
> 
> Strictly this need NOT be true.
> == compares a and b, and if they both address the same object, then
> the answer is true, otherwise false.
> = is a method implemented in the receiver's class.

Strictly speaking, even this need not be true.
In a formal sense '==' is also a binary message implemented
in the receiver's class.  Whether particular implementations
of the Smalltalk language optimize it away from programmer
control is another issue.

[good explanation of = snipped]

> In general, programmers try to make = work as you would expect,

[good example of case-insensitive = snipped]

> Smalltalk does not force any particular definition of =

Absolutely true.  It is simply a binary message.

However, it is highly likely (IMHO) that using this
freedom to define a method for == which does not
	"Answer whether parameterObject is
	identically the same object as the receiver."
or a method for = which does not
	"Answer whether parameterObject is equal to receiver
	[in the implied context]."
would appear to most of us as overly 'tricky' and misleading.

The usual difficulty with = is in communicating and/or determining
the implied context.  For example, consider two objects, o1, o2.
	o1 holds a reference to a car.
	o2 holds a reference to a bus.
Are they = ?
	o1 holds a reference to a Ford.
	o2 holds a reference to a Chrysler.
Are they = ?
	o1 holds a reference to a 1965 Ford Mustang.
	o2 holds a reference to a 1965 Ford Thunderbird.
Are they = ?

This can be continued to an apparently absurd level of detail,
yet in a certain context the fact that [one of the two male passengers
in one 1965 blue Ford Mustang with a woman driver and two male
passengers is wearing a black hat], while in another [1965 blue Ford
Mustang with a
woman driver and two male passengers, both male passengers wear red
caps]

means that = should answer false.

This gets particularly interesting when it is desirable to allow the
implied context of equality to change on the fly.  Granted, there are
ways to accomplish this which do not require the meaning of = to change,
but recursive implementations of knowledge representation have many
advantages, so a clean way of expressing, and changing, the implied
context is, to me, a useful goal.

I am exploring the notion of specifying implied context, in a generic
way, and I'd like something that would refactor all the way to Object,
or at least Collection, as a standard form.

Anyone have ideas on this?

-jim

