Re: [Pharo-project] Collection>>select: aBlock ifNoneTakeAsDefault: aDefaultValue

2009-12-27 Thread Stéphane Ducasse
The question is how much will we have to backport. Because we do not have that horse power to do that for each little details. I would only backport really important fixes. Stef On Dec 27, 2009, at 7:58 PM, Nicolas Cellier wrote: > 2009/12/27 Lukas Renggli : >>> Julian: we (stef and I) have som

Re: [Pharo-project] Collection>>select: aBlock ifNoneTakeAsDefault: aDefaultValue

2009-12-27 Thread Nicolas Cellier
2009/12/27 Lukas Renggli : >> Julian: we (stef and I) have something we don't understand. The >> implementation of ifEmpty: is like this in Pharo: >> >> Collection >> ifEmpty: aBlock >>     "Evaluate the block if I'm empty" >> >>     self isEmpty ifTrue: [ ^aBlock value ] > > In Pharo 1.0rc1 it loo

Re: [Pharo-project] Collection>>select: aBlock ifNoneTakeAsDefault: aDefaultValue

2009-12-27 Thread Lukas Renggli
> Julian: we (stef and I) have something we don't understand. The > implementation of ifEmpty: is like this in Pharo: > > Collection >> ifEmpty: aBlock >     "Evaluate the block if I'm empty" > >     self isEmpty ifTrue: [ ^aBlock value ] In Pharo 1.0rc1 it looks like this: Collection>>ifEmpty: a

Re: [Pharo-project] Collection>>select: aBlock ifNoneTakeAsDefault: aDefaultValue

2009-12-27 Thread Mariano Martinez Peck
On Sat, Dec 26, 2009 at 11:44 PM, Julian Fitzell wrote: > Personally, I would rather see #ifEmpty: modified to return self in > the false case like #ifNil: does. The only in-image sender I can find > that even uses the return value seems to actually expect this > behaviour anyway. :) > > Julian:

Re: [Pharo-project] Collection>>select: aBlock ifNoneTakeAsDefault: aDefaultValue

2009-12-27 Thread Lukas Renggli
>> Personally, I would rather see #ifEmpty: modified to return self in >> the false case like #ifNil: does. The only in-image sender I can find >> that even uses the return value seems to actually expect this >> behaviour anyway. :) +1 > what is the behavior in other dialects ? :) > Do you have s

Re: [Pharo-project] Collection>>select: aBlock ifNoneTakeAsDefault: aDefaultValue

2009-12-27 Thread Stéphane Ducasse
I forgot open a bug tracker entry because we should not lose the suggestion. On Dec 26, 2009, at 11:44 PM, Julian Fitzell wrote: > Personally, I would rather see #ifEmpty: modified to return self in > the false case like #ifNil: does. The only in-image sender I can find > that even uses the retur

Re: [Pharo-project] Collection>>select: aBlock ifNoneTakeAsDefault: aDefaultValue

2009-12-27 Thread Stéphane Ducasse
On Dec 26, 2009, at 11:44 PM, Julian Fitzell wrote: > Personally, I would rather see #ifEmpty: modified to return self in > the false case like #ifNil: does. The only in-image sender I can find > that even uses the return value seems to actually expect this > behaviour anyway. :) what is the beh

Re: [Pharo-project] Collection>>select: aBlock ifNoneTakeAsDefault: aDefaultValue

2009-12-26 Thread Bart Gauquie
Hi, that seems like a very good suggestion. Is more general usable also. Regards, Bart On Sat, Dec 26, 2009 at 11:44 PM, Julian Fitzell wrote: > Personally, I would rather see #ifEmpty: modified to return self in > the false case like #ifNil: does. The only in-image sender I can find > that e

Re: [Pharo-project] Collection>>select: aBlock ifNoneTakeAsDefault: aDefaultValue

2009-12-26 Thread Julian Fitzell
Personally, I would rather see #ifEmpty: modified to return self in the false case like #ifNil: does. The only in-image sender I can find that even uses the return value seems to actually expect this behaviour anyway. :) Then you could simply write: (aCollection select: [:ea | ...]) ifEmpty: [ ..

[Pharo-project] Collection>>select: aBlock ifNoneTakeAsDefault: aDefaultValue

2009-12-26 Thread Bart Gauquie
Dear all, While developing some code, I made following extension of the Collection protocol: select: aBlock ifNoneTakeAsDefault: aDefaultValue |result| result := self select: aBlock. (result isEmpty) ifTrue: [^self class with: aDefaultValue] ifFalse: [^result]. Maybe this co