What about making explicit in the comment that the arg is ignored if not needed?

Something like

cull: anArg
��� "Execute the receiver with one or zero argument.� If the receiver needs less than one argument, the argument is ignored.
����� ..."

Guille

On Thu, Aug 18, 2011 at 4:17 AM, Henrik Johansen <henrik.s.johansen@veloxit.no> wrote:

On Aug 18, 2011, at 8:52 44AM, Philippe Marschall wrote:

> On 17.08.2011 22:57, Henrik Sperre Johansen wrote:
>> On 17.08.2011 22:29, Philippe Marschall wrote:
>>> On 17.08.2011 22:17, St�phane Ducasse wrote:
>>>> I wrote
>>>>
>>>>
>>>> cull: anArg
>>>> � �"Execute the receiver with one or zero argument.
>>>>
>>>> � �[ 1 + 2 ] cull: 5
>>>> � � � �returns 3
>>>> � �[ :x | 1+ 2 + x] cull: 5
>>>> � � � �returns 8
>>>> � �"
>>>> � �^numArgs = 0
>>>> � � � �ifTrue: [self value]
>>>> � � � �ifFalse: [self value: anArg]
>>>>
>>>
>>> So it's like #valueWithPossibleArgument:?
>> Almost.
>> cull: raises error if given blocks with too many args,
>> valueWithPossibleArgument(s): evaluates with the extra args as nil.
>>> �Why do we need two methods
>>> that do the same thing?
>> Because valueWithPossibleArguments was there first, and we can't simply
>> remove it.
>> cull is more natural to use in 99.9% of the cases.
>>
>> Also, #cull: protocol only goes up to 4 arguments, mirroring #value:
>> (#cullWithArguments: not being present is mostly an oversight though... )
>
> So we #valueWithPossibleArgument:?
>
> Cheers
> Philippe
#valueWithPossibleArgument: / #valueWithPossibleArgs: / #valueWithEnoughArguments: all execute the block with nil args if passed too few.
#cull:'s raise an error.
Other than that, they are equivalent from a users POV, yes.

Cheers,
Henry