[squeak-dev] #valueWithPossibleArgument: vs. #cull:

Nicolas Cellier nicolas.cellier.aka.nice at gmail.com
Mon May 20 21:22:55 UTC 2019


Le lun. 20 mai 2019 à 21:19, Chris Muller <asqueaker at gmail.com> a écrit :

>
>> Hi, there.
>>
>> I think that all (6) sends in Trunk to #valueWithPossibleArgument: can be
>> replaced with #cull:, which is more flexible.
>>
>
> It may be that these replacements can occur in trunk, but please don't let
> it lead to, "ah, now valueWithPossibleArgument: has no senders so we can
> deprecate it."   ;-/
>
> For arguments that accept a Collection, coercing a single object into a
> single-element collection is a useful pattern for improving API usability.
> #valueWithPossibleArgument: does that.
>
>
>
>
>>
>>
>> Does anyone recall the story of #cull:? Maybe we should just implement #valueWithPossibleArgument:
>> on MessageSend (and maybe Symbol) to make it more consistent?
>>
>
> +1.  We should add #valueWithPossibleArgument: to MessageSend (and maybe
> Symbol), and keep it on BlockClosure too.  It is useful separately from
> #cull:[...] for certain situations.
>
> Best,
>   Chris
>
>
valueWithPossibleArgument: does one thing more than cull:
it fill missing arguments with nil
I don't know if this is super useful... I find the feature questionable
personnally.
Anyway, no sender is using this feature, so all senders could rather use
cull:

valueWithPossibleArgs: has no equivalent because no cull message takes an
Array of arguments.
valueWithPossibleArgs: is already understood by MessageSend while
valueWithPossibleArgument:
is not which is somehow surprising.

I'm not sure at all that these two selectors would be good to add to Symbol.
For example, Symbol only understand cull: but not cull:cull: nor does it
understand valueWithArguments:



>> For context, here is how I stumbled on it:
>> #(1 2 3) collect: #even. "Works."
>> 1 ifNotNil: #even. "Works."
>> #(1) ifNotEmpty: #first. "Does not work."
>>
>> Please note that this question is not about "#(1 2 3) collect: #even"
>> versus "#(1 2 3) collect: [:ea | ea even]". ;-) This is more like a case of
>> surprising inconsistency...
>>
>> Best,
>> Marcel
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20190520/b75f64a1/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image.png
Type: image/png
Size: 20228 bytes
Desc: not available
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20190520/b75f64a1/attachment.png>


More information about the Squeak-dev mailing list