[squeak-dev] Re: terse Object concatenation

Andreas Raab andreas.raab at gmx.de
Wed Sep 22 17:56:56 UTC 2010


On 9/22/2010 10:23 AM, Bert Freudenberg wrote:
> Stringification of any object in String>>, was only added last year. Until then, there was no generic protocol involving #, it was only for special classes (Collections, Exceptions, Sounds).
>
> It made (some) sense for Strings because it's just too convenient being able to write ('the value is ', aNumber) without having to convert aNumber to a String first.
>
> For making Arrays I prefer the brace notation. E.g. if you want to return two objects from a method you still would need to write ^{a. b} because if you write ^a,b would break if the first object happens to be a collection. Also, brace notation is more efficient with more than 2 elements because it avoids unnecessarily copying the intermediate collections.
>
> That said, I wouldn't really mind adding your feature.

Same here. I'm not a strong proponent of object-object concatenation 
(though I *am* a strong proponent of string-object concatenation :-) but 
I don't mind it either. I can sort of see the appeal of writing "1, 2" 
but it's just something that I don't do often outside of literal string 
concatenation.

 From my view brace syntax is slightly advantageous for complex 
constructs since it avoids additional parenthesis and can be indented 
properly as in:

	self doWithArgs: {
		self methodFoo: 42.
		17 sqrt.
		'Hello', 'World'.
	}

vs.

	self doWithArgs: (self methodFoo: 42), 17 sqrt, ('Hello', 'World')

But then again I really don't feel strongly about it.

Cheers,
   - Andreas



More information about the Squeak-dev mailing list