Appending a character to a string
nice
ncellier at ifrance.com
Sun Feb 11 17:21:53 UTC 2007
Philippe Marschall a écrit :
> 2007/2/11, Jon Hylands <jon at huv.com>:
>> On Sun, 11 Feb 2007 18:00:21 +0100, Damien Cassou
>> <damien.cassou at laposte.net> wrote:
>>
>> > However, #, only works with collections. I'm obliged to use #copyWith:
>> > instead. Is there a pattern to do this without using Streams ?
>>
>> self doSomethingWith: myString, (String with: Character cr),
>> anotherString.
>
> I find that quite ugly. For many things like this there are:
> String space
> String cr
> String crlf
> String tab
>
>
> Philippe
>
>> Later,
>> Jon
>>
>> --------------------------------------------------------------
>> Jon Hylands Jon at huv.com http://www.huv.com/jon
>>
>> Project: Micro Raptor (Small Biped Velociraptor Robot)
>> http://www.huv.com/blog
>>
>>
>
>
Hello Damien,
Concatenating characters with #, would not be shocking me.
Maybe i'am short minded, but i do not see what else would be the meaning
of Character>>#,
Of course, you would have String>>#, implementation complexified, and
semantic of #, not exactly the super one, but then what?
Doing so, String cr,tab and co would become quite needless.
This could eventually be generalized to any immediate collection
(ByteArray, WordArray, FloatArray and co).
However, generalization to any object and any collection (pointer form)
would be ambiguous, since we can have collection of collection...
I already saw #, used for creating 3D Points (VW Jun), or to concatenate
numbers into vectors (Jeffrey Hallman's Smallpack), and i used it myself
once for similar purposes (constructing matrices with , for column
concatenation and ,, for row concatenations).
Problem of such extensions is that they are likely to collide if you
want to load several packages in one image... Not recommanded
However, I do not see yet a good readon to not try that for Character.
Nicolas
More information about the Squeak-dev
mailing list
|