About {} and its limits

Frank Shearar Frank.Shearar at rnid.org.uk
Mon Feb 14 16:35:26 UTC 2005


Alexandre Bergel <bergel at iam.unibe.ch> wrote:

> Brent Pinkney said:

> > Syntactic suger. Like -> instead of Association>>key:value:
> 
> Yep, I know that. But I see the Array>>brace* methods as 
> redundant. For instance, 
> -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
> Array>>braceWith: a with: b 
> 	"This method is used in compilation of brace constructs.
> 	It MUST NOT be deleted or altered."
> 
> 	| array |
> 	array _ self new: 2.
> 	array at: 1 put: a.
> 	array at: 2 put: b.
> 	^ array
> -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
> 
> and 
> -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
> ArrayedCollection>>with: firstObject with: secondObject 
> 	"Answer a new instance of me, containing firstObject 
> and secondObject."
> 
> 	| newCollection |
> 	newCollection _ self new: 2.
> 	newCollection at: 1 put: firstObject.
> 	newCollection at: 2 put: secondObject.
> 	^newCollection
> -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
> 
> the brace* methods are copies of methods provided by ArrayedCollection

At first I though that maybe, because of the comments, that we somehow wouldn't want the meaning of {} to change. But {} is meant to mean precisely Array>>with:with:<etc>, not so?

In which case I think Alexandre's right, and the brace* methods should call the ArrayedCollection methods:

Array>>braceWith: a with: b 
	^ self with: a with: b.

Or have I missed some subtlety?

frank


*******************************************************************
This email and attachments (if any) must be swept for viruses before opening. Their contents may be confidential or privileged and are intended solely for the named recipient. If you are not the intended recipient and you have received this email in error you must not read or use this email and should notify RNID on: +44 (0) 20 7296 8282.

 

RNID, Registered Office 19-23 Featherstone Street, London EC1Y 8SL No. 454169 (England, Registered Charity No. 207720)

********************************************************************




More information about the Squeak-dev mailing list