Well, in Pharo you now have:
Symbol>>value: anObject
^anObject perform: self.
So, the implementation based on #value: can make Symbols and Blocks
polymorphic. In the case of asSortBlock, you could put it in a Trait
and implement it both for Block and for Symbol in one place :).
Cheers,
Doru
On 1 Apr 2009, at 11:55, Simon Denier wrote:
On 1 avr. 09, at 10:46, Tudor Girba wrote:
> Hi,
>
> asSortBlock is implemented in CodeFoo and CodeFoo is apparently
> under MIT (see the bundle comments in VW).
>
> anyway, another implementation would be:
>
> ^ [:a :b | (a value: self) <= (b value: self)]
I suppose you meant (might be different in VW though)
^ [:a :b | (a perform: self) <= (b perform: self) ]
Very elegant :)
It's funny how one can be easily get obfuscated when dealing with
meta stuff
>
> Cheers,
> Doru
>
>
> On 30 Mar 2009, at 19:55, Simon Denier wrote:
>
>> I need the following method from VW to run some tests in SqMoose.
>> Does anybody have an idea about its licence? Does not seem to be
>> part of our own extensions :(
>>
>> It's not especially difficult to reimplement one, anyone can come
>> up with a Squeak/Pharo equivalent (although it works as is under
>> Pharo, perhaps there is a better way)
>>
>> Symbol>>asSortBlock
>> "Answer a sort block, which evaluates this symbol for both
>> arguments
>> and compares the resulting values"
>>
>> | stream |
>> stream := (String new: self size * 2 + 14) writeStream.
>> stream
>> nextPutAll: '[:a :b | a ';
>> nextPutAll: self;
>> nextPutAll: ' <=b ';
>> nextPutAll: self;
>> nextPut: $].
>> ^Compiler evaluate: stream contents
>>
>> --
>> Simon
>>
>>
>>
>> _______________________________________________
>> Moose-dev mailing list
>> Moose-dev(a)iam.unibe.ch
>>
https://www.iam.unibe.ch/mailman/listinfo/moose-dev
>
> --
>
www.tudorgirba.com
>
> "Every now and then stop and ask yourself if the war you're
> fighting is the right one."
>
>
>
> _______________________________________________
> Moose-dev mailing list
> Moose-dev(a)iam.unibe.ch
>
https://www.iam.unibe.ch/mailman/listinfo/moose-dev
>
--
Simon
_______________________________________________
Moose-dev mailing list
Moose-dev(a)iam.unibe.ch
https://www.iam.unibe.ch/mailman/listinfo/moose-dev
--
www.tudorgirba.com
"Problem solving should be concentrated on describing
the problem in a way that is relevant for the solution."