http://code.google.com/p/pharo/issues/detail?id=1991

Purpose of code changes on this branch:
Provide a cull: protocol on BlockClosure, equivalent to value: protocol, 
but taking N or more args, where N is numArgs. 
This is already provided by valueWithPossibleArgs:, but this only takes an 
array, and fills out missing arguments if block numArgs is higher than 
array size, as well as leading to extra syntax when your number of 
variable args is low and constant compared to cull:

f.ex.
ifNotNil: ifNotNilBlock
        ^ifNotNilBlock valueWithPossibleArgs: {self}
turns into:
ifNotNil: ifNotNilBlock
        ^ifNotNilBlock cull: self

and: 

ifError: errorHandlerBlock
        ^ self on: Error do: [:ex |
                errorHandlerBlock valueWithPossibleArgs: {ex description. 
ex receiver}]
turns into:
ifError: errorHandlerBlock
        ^ self on: Error do: [:ex |
                errorHandlerBlock cull: ex description cull: ex receiver]

When reviewing my code changes, please focus on:

- Code clarity (there are speedier but uglier implementations)
- Unnecessary array creation
- Usefulness






On Feb 18, 2010, at 2:23 PM, Henrik Johansen wrote:

> Refactoring the AXAnnouncements abit so there's no separate classes for
> 0-, 1-, and 2-arg blocks, and really missing these methods from
> VisualWorks...
> cull: is equivalent to value: protocol except they accept block with N
> or less blockArgs
> Yes, I know valueWithEnoughArguments:/valueWithPossibleArgs: provide the
> same functionality, but the code looks much less nice using them, you
> end up constructing arrays needlessly etc.
> Look at the senders of valueWithPossibleArgs: for examples, very few of
> those actually need the ability to accept blocks with more arguments
> than they provide, and would also look nicer with cull:.
> 
> Would anyone object strongly to adding the cull:, cull:cull: methods in
> core instead of putting them as extension methods?
> 
> Cheers,
> Henry
> 
> _______________________________________________
> Pharo-project mailing list
> Pharo-project@lists.gforge.inria.fr
> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project


_______________________________________________
Pharo-project mailing list
Pharo-project@lists.gforge.inria.fr
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project

Reply via email to