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.

Cheers,
Henry

_______________________________________________
Pharo-project mailing list
[email protected]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project

Reply via email to