Common enough to include it?

Ron Teitelbaum Ron at USMedRec.com
Tue Jan 22 19:00:53 UTC 2008


Hi All,

This was my objection too.  There was someone on the beginners list that was
having trouble reading similar code.  When it turned out to be a trick of
Symbol>>value, I recommended not using it because it was hidden and hard for
some users to understand.  

collect: aBlockOrSymbol  
	"Symbols can be sent in as a message to be performed.  Results are
collected for each element. 	
	see: Symbol>>value"

might make it easier to understand, but it still feels like a trick.

Ron

> -----Original Message-----
> From: Sebastian Sastre
> 
> Hi Bert,
> 
> 	as a convenience I don't present objections. The usability problem I
> saw on that is the convenience being a hidden feature. Ofcourse
> Collection>>"collect: aValuableOrSymbol" could suggest it's existence
> palliating that.
> 
> 	cheers,
> 
> Sebastian Sastre
> 
> 
> > -----Mensaje original-----
> > De: squeak-dev-bounces at lists.squeakfoundation.org
> > [mailto:squeak-dev-bounces at lists.squeakfoundation.org] En
> > nombre de Bert Freudenberg
> > Enviado el: Martes, 22 de Enero de 2008 15:41
> > Para: The general-purpose Squeak developers list
> > Asunto: Re: Common enough to include it?
> >
> > They "accept" anything that understands #value:. There are
> > different opinions about Symbol>>#value: being a good idea or
> > not. It's certainly convenient.
> >
> > - Bert -
> >
> >
> > On Jan 22, 2008, at 18:35 , Sebastian Sastre wrote:
> >
> > > Oh great. I had the idea that they where accepting only
> > blocks. Cool,
> > >
> > > 	cheers,
> > >
> > > Sebastian Sastre
> > >
> > >
> > >
> > >> -----Mensaje original-----
> > >> De: squeak-dev-bounces at lists.squeakfoundation.org
> > >> [mailto:squeak-dev-bounces at lists.squeakfoundation.org] En
> > nombre de
> > >> Andreas Raab Enviado el: Martes, 22 de Enero de 2008 15:15
> > >> Para: The general-purpose Squeak developers list
> > >> Asunto: Re: Common enough to include it?
> > >>
> > >> Both patterns effectively exist:
> > >>
> > >>    (1 to: 3) collect: #printString
> > >>
> > >> Cheers,
> > >>    - Andreas
> > >>
> > >> Sebastian Sastre wrote:
> > >>> Hi there,
> > >>>
> > >>> 	I've found a couple of simple but nice conveniences in
> > >> collections:
> > >>>
> > >>> 	A) To be able to do things like:
> > >>>
> > >>> 		persons collectAspect: #surname
> > >>>
> > >>> collectAspect: aSymbol
> > >>> 	"Collects the element's answer to aSymbol"
> > >>> 	^ self collect:[:each| each perform: aSymbol]
> > >>>
> > >>> 	B) To be able to do things like:
> > >>>
> > >>> 		1 to: 12 collect:[:i| (Month nameOfMonth: i)
asString ]
> > >>>
> > >>> to: stop collect: aBlock
> > >>> 	"Evaluate aBlock and adds it's answer to results
> > >>> 	for each element of the interval (self to: stop by: 1)."
> > >>> 	| nextValue results |
> > >>> 	nextValue _ self.
> > >>> 	results := OrderedCollection new.
> > >>> 	[nextValue <= stop]
> > >>> 		whileTrue:
> > >>> 			[results add: (aBlock value: nextValue).
> > >>> 			nextValue _ nextValue + 1].
> > >>> 	^ results
> > >>>
> > >>> 	Maybe they are universal enough to include in base?
> > >>>
> > >>> 	cheers,
> > >>>
> > >>> Sebastian Sastre
> > >>> PS: I'm proposing to use this #collectAspect: in the very
> > >> same way of
> > >>> #pluck as you can found it in Prototype enumerable, a kind of
> > >>> collection abstraction for javascript.
> > >>>
> > >>>
> > >>>
> > >>
> > >>
> > >
> > >
> >
> >
> >
> >
> 





More information about the Squeak-dev mailing list