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

Chris Muller asqueaker at gmail.com
Mon May 20 19:18:55 UTC 2019


>
>
> 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


>
> 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/2c57b158/attachment-0001.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/2c57b158/attachment-0001.png>


More information about the Squeak-dev mailing list