[squeak-dev] Re: intersect: when intsersects: is false
eliot.miranda at gmail.com
Sun Jun 20 19:18:10 UTC 2010
On Sun, Jun 20, 2010 at 12:02 PM, Nicolas Cellier <
nicolas.cellier.aka.nice at gmail.com> wrote:
> 2010/6/20 Louis LaBrunda <Lou at keystone-software.com>:
> > On Sun, 20 Jun 2010 11:07:23 +0200, Joachim Geidel
> > <joachim.geidel at onlinehome.de> wrote:
> >>One could just
> >>leave it as it is, because the precondition for answering a "correct"
> >>rectangle is that the receiver and the argument intersect. If they don't,
> >>answer is undefined, which means that whatever is answered is correct in
> >>mathematical sense.
> > I urge some caution here. If "whatever is answered is correct in a
> > mathematical sense" is true then returning any rectangle like (100 at 100)
> > corner: (150 at 150) would be correct, clearly that is not the case. In
> > Smalltalk, nil is undefined, nil is probably the "correct" answer.
> Yes, this is tempting.
> However from a pragmatic point of view that would mean that:
> - either every call must be protected with an intersects: test or (...
> intersect ...) ifNil: [...]
> - or UndefinedObject must understand Rectangle protocol
> Answering an empty rectangle seems more simple with this respect.
Tempting but mad. It will break lots of code. Instead, simply use a
different selector. For example, intersection: is used by Collection,
Matrix and Timespan, all of which have different semantics, so the argument
that overloading Collection>>intersection: and Rectangle>>intersection:
doesn't hold; intersection: is already overloaded.
Recently I've noticed that someone changed the semantics Integer>>hex in
Squeak from 38 to 4.1 for no good reason. There were plenty of other
selectors that could have been used for the new functionality (i.e. printing
without a leading 16r). This kind of careless breaking of
backwards-compatibility is an entirely avoidable really bad thing™.
> > -----------------------------------------------------------
> > Louis LaBrunda
> > Keystone Software Corp.
> > SkypeMe callto://PhotonDemon
> > mailto:Lou at Keystone-Software.com http://www.Keystone-Software.com
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Squeak-dev