[squeak-dev] Re: What is equivalence? (was: The Trunk: Collections-eem.603.mcz)

Eliot Miranda eliot.miranda at gmail.com
Wed Feb 4 22:13:44 UTC 2015

On Wed, Feb 4, 2015 at 1:40 PM, Chris Muller <ma.chris.m at gmail.com> wrote:

> >> If #isDictionary refers to particular API and behaviors, one could
> >> argue that a BTree should answer true to #isDictionary, because it has
> >> similar API and behaviors.  In the context of _equivalence testing_
> >> though, a BTree is not a Dictionary.
> >>
> >> So as long as we interpret the various #isSomeType methods as truly of
> >> *that type* (same semantics as isKindOf:), and not "similar to", then
> >> I can see no side-effects (unless someone added #isDictionary to
> >> BTree, of course).  However, we may want to visit the other #=
> >> implementations elsewhere in the system too, unless this would appear
> >> to be an inconsistency producing its own odor of sorts.
> >
> > "similar to" is vague.  I *don't* interpret isFoo methods as isKindOf:
> (and
> > think that most experienced Smalltalk programmers don't either).
> > In
> > Smalltalk type = protocol.  So these methods imply that an object
> implements
> > a given set of messages, not that they are of any given class.
> Then I am very interested to know your thoughts about my BTree
> question, above, which shares the same protocol as Dictionary.  Should
>     (BTree new at: 3 put: 'three'; yourself) = (Dictionary new at: 3
> put: 'three'; yourself)
> return true?  Why or why not?

Duck typing applies here, if it quacks like a duck.  So if your BTree
behaves like a Dictionary to the extent that e.g. MethodDictionary does
(MethodDictionary supports associationAt: but isn't answering an
association within it cuz it does't contain associations) then sure, it's a
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20150204/e376b134/attachment.htm

More information about the Squeak-dev mailing list