abergel wrote > ... > why printString is used and not asString? > ...
As stepharo pointed out, #asString is a conversion method. It is often misused and misrepresented (see especially Java's toString() method). It is important to clearly distinguish purpose, so we often see #printString, #displayString, #storeString, as well as #asString. With #asString, one could envision saying "1 asString asNumber" and recreating the original object. That is what we expect from conversion methods (oversimplified, but I think you get the point). Most objects cannot do that. #printString is meant to portray the object in sufficient detail that one can recognize it, but not necessarily recreate it. (typically of use to a programmer, but not necessarily only to programmers) #displayString is meant to provide a suitable representation of an object for a user of the system. (typically an application user more so than a programmer, but really for anybody). And #storeString is meant to provide a representation that would allow creation of an equivalent object when evaluated. Back to your original question. One could override Object's implementation of #logCr in String to do as you would like (it seems reasonable enough, although you would probably want to ensure Symbol works differently from String). Alternatively, one could (and perhaps should) define a #logString with the default implementation using #printString and subclass that method where appropriate. e.g. #printString often truncates long collections with a "...". #logString probably would not do that. -- View this message in context: http://forum.world.st/Object-logCr-tp4799595p4800051.html Sent from the Pharo Smalltalk Developers mailing list archive at Nabble.com.
