[Cuis] String concatenation with non-strings

David Graham dgraham at unthinkable.org
Tue Dec 10 14:42:36 CST 2013


Thanks Juan.  No need to change, it was more of a philosophical 
curiosity.  I noticed the bluebook had a similar example (pg 533), and 
sent printString to the number before concatenating.

On 12/8/13 11:36 AM, Juan Vuletich wrote:
> Hi David,
>
> This was never discussed... I think that going too far in that 
> direction could make Cuis look like Perl. Is there a god reason to do it?
>
> Cheers,
> Juan Vuletich
>
> On 12/6/2013 2:16 PM, David Graham wrote:
>> Hi All,
>> I occasionally run into this issue when porting code and was curious 
>> if there is a specific reason why the String>>, method doesn't send 
>> an "asString" message to any non-String objects being concatenated?
>>
>> For example, if I open a workspace and do a print-it on the following:
>> 'test: ', 5
>> It errors and the debugger shows that the message ends up being 
>> handled by Sequenceable collection which fails.
>>
>> Here is the Cuis code from String>>,:
>> , aStringOrText
>>     ^ (aStringOrText is: #Text)
>>         ifTrue: [ self asText , aStringOrText ]
>>         ifFalse: [ super , aStringOrText ].
>>
>> Squeak:
>> , anObject
>>     "Concatenate the argument to the receiver.
>>         Transcript cr; show: 'The value is: ', 3.
>>     "
>>     ^ self copyReplaceFrom: self size + 1
>>           to: self size
>>           with: anObject asString
>>
>> Regards,
>> David
>>
>> _______________________________________________
>> Cuis mailing list
>> Cuis at jvuletich.org
>> http://jvuletich.org/mailman/listinfo/cuis_jvuletich.org
>>
>





More information about the Cuis mailing list