Den 19.02.2010 12:40, skrev Levente Uzonyi: > On Fri, 19 Feb 2010, Henrik Johansen wrote: > >> Den 18.02.2010 21:55, skrev Stéphane Ducasse: >>> henrik >>> >>> I'm trying to get the pros and cons of cull: >>> So am'I correct that this is useful only for situation where we have >>> a block and we do not know >>> upfront its number of argument: = places where valueWithPossibleArgs: >>> Now what cull: offers is that the client does not have to create the >>> array. >>> >>> I did not check your implementation. >>> >>> Stef >>> >> It's useful where you may or may not be interested in all the arguments >> passed to a block. >> Announcement and Exception handling are good examples. It covers the >> same bases as valueWithPossibleArgs:, with the exception it does not >> expand with nil args if block has more args than the corresponding >> message sent. >> >> Pros: >> - Maps well with to the value:, value:value, etc. protocol >> - Your code looks cleaner (imo), since you don't have to put the args in >> an array, and it's clear in a heart beat how many args you can choose to >> use in your block. >> - It's faster than valueWithPossibleArgs, since you don't have to put >> your args in an array (Also you avoid a max of 2 extra array creations >> as part of the method) >> >> Cons: >> - Functionality is already provided by valueWithPossibleArgs: (That's a >> superset though, if you need the exact functionality of cull, your code >> will end up even hairier since you need an arg size check before calling >> valueWithPossibleArgs:) >> - Portability. VW and GNU ST has them, Squeak does not, not sure about >> other implementations. > > Even though I'm just a lurker here, I think you should add this > feature to Pharo. Of course I'd add the "uglier" implementation (as we > discussed it with Henry in January), since I think it's not "uglier" > and gives better performance (~1.3x faster for #cull:cull: if the > block has less than 2 arguments while same performance if the block > has 2 arguments). > > > Levente Well, ugly was a strong word. Reusing less, aka. shorter is a better choice, I guess.
Cheers, Henry PS. In VisualWorks, the two perform equally. *Wishing for a Cog VM to test on* :) PPS. For those interested, the alternative, faster version Levente made can be found at http://paste.lisp.org/display/93130 _______________________________________________ Pharo-project mailing list [email protected] http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
