[BUG] equivalence between strings and symbols

Stephan Rudlof sr at evolgo.de
Wed Apr 12 15:52:14 UTC 2000


Richard and others,

this arises two questions for me:

Btw: I don't have a usable document describing the standard, just a very
buggy html-Version; I think there should be usable standard describing
documents available *without* money, if someone wants to have a
standard...

"R. A. Harmon" wrote:
> 
> At 09:57 PM 4/11/00, Lex Spoon wrote:
> >"R. A. Harmon" <harmonra at webname.com> wrote:
> >
> >> I am trying to implement an ANSI conforming #=.  As I understand it, #abc
> >> (an instance of class Symbol) = 'abc' (an instance of class String) would be
> >> non-conforming implementation as their classes are different.
> >>
> >
> >Apparently it's ambiguous.  Allen Wirfs-Brock gave a pretty good
> >argument earlier today.
> 
> As I read his explanation the ANSI Standard is not ambiguous, it just allows
> various implementation.  The SequenceableCollection >> #= specification:
> 
> Refinement: <sequenceReadableCollection>
> Unless specifically refined, the receiver and operand are equivalent if all
> of the following are true:

Does this definition mean:
'Unless specifically refined, the receiver and operand are equivalent if
all
of the following are true, and *** otherwise they are *not* equivalent
***:'?

Who refines a definition (standard or implementation or both)?

Regards,

Stephan

> 
>         1. The receiver and operand are instances of the same class.
>         2. They answer the same value for the #size message.
>         3. For all indices of the receiver, the element in the receiver at a
>                 given index is equivalent to the element in operand at the
>                 same index.
> 
> means same class when it says same class.
> 
> >So we can choose whichever way we like, and just remember that if we
> >want to write portable Smalltalk code, we can't rely on it working one
> >way or the other.  :(
> 
> --- Allen Wirfs-Brock:
> 
> The ANSI Standard was trying to allow for this possibility. I think it
> succeeded in allowing this.
> 
> Java also essentially takes the above approach. There is only a single
> String class. The intern() method of a String returns a unique "canonical"
> instance of the String that corresponds to the receiver.  Thus such a
> canonical string has essentially the same semantics as a Smalltalk Symbol
> but only a single class is used to represent both canonical and
> non-canonical strings.
> 
> ---
> 
> Badly simplified, we can choose to implement String and Symbol as a single
> class, say StringSymbol, used to represent both and only then would:
> 
>         #abc (an instance of class StringSymbol)
>                 = 'abc' (an instance of class StringSymbol) -> true
> 
> As I read it there are other possible variations in implementation.
> 
> --
> Richard A. Harmon          "The only good zombie is a dead zombie"
> harmonra at webname.com           E. G. McCarthy
> Spencer, Iowa

-- 
Stephan Rudlof (sr at evolgo.de)
   "Genius doesn't work on an assembly line basis.
    You can't simply say, 'Today I will be brilliant.'"
    -- Kirk, "The Ultimate Computer", stardate 4731.3





More information about the Squeak-dev mailing list