Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!usc!wuarchive!udel!ee.udel.edu From: new@ee.udel.edu (Darren New) Newsgroups: comp.lang.smalltalk Subject: Re: Please Explain Difference Between $A And 'A' Message-ID: <49912@nigel.ee.udel.edu> Date: 5 Apr 91 19:20:40 GMT References: <40923@cup.portal.com> Sender: usenet@ee.udel.edu Organization: University of Delaware Lines: 36 Nntp-Posting-Host: snow-white.ee.udel.edu In article <40923@cup.portal.com> Will@cup.portal.com (Will E Estes) writes: >In learning Smalltalk, I am finding cases where semantically identical, >but logically distinct, object types do not get treated the same. One >case is point is the difference between single character objects (e.g., >$C) and single character string arrays (e.g., 'C'). 'C' and $C are clearly not "semantically identical" or you wouldn't be having this problem, eh? :-) The problem is the 'C' is a string which happens to be one character long and $C is a single character. (The distinction is there in most lower- level languages, too.) Would you want '3' = 3 to work? How about '18.2' = 18.2 or '3/4' = 0.75 ? >1) Is this example evidence of bad implementation on Digitalk's part, >or is this considered good Smalltalk style? In other words, should >it be a goal in writing Smalltalk methods to make semantically identical >things work together. Or does good Smalltalk live by the "separate, >but equal" rule? See above. Where do you stop? It's good Smalltalk. That's why it is possible to redefine equality operators on a class-by-class basis. Try ('C' at: 1) < $C or something like that. Maybe $C asString < 'C'. Depends on exactly what conversions your particular image includes. >2) Are there many other instances of this sort of thing in Smalltalk? >Maybe someone could review the most common gotchas.... Lots of them. You'll find them. -- Darren -- --- Darren New --- Grad Student --- CIS --- Univ. of Delaware --- ----- Network Protocols, Graphics, Programming Languages, FDTs ----- +=+=+ My time is very valuable, but unfortunately only to me +=+=+ + When you drive screws with a hammer, screwdrivers are unrecognisable +