[Cuis-dev] #valueEnsured return value

Hernán Wilkinson hernan.wilkinson at 10pines.com
Mon Feb 27 04:18:25 PST 2023


hmmm I'm not sure it is a good idea because it goes against the expected
return value of #ensure:
I mean, #valueEnsured is just a shortcut for [] ensure: [...], and #ensure:
returns the return value of evaluating the receiver block, not the
parameter block. The receiver block is [] so it should return nil ([]
value).
Currently it is not returning nil because it is implemented like this:
[] ensure: self
and it should be:
^[] ensure: self

Now I'm thinking... I do not understand the need for #valueEnsured, why not
just send #value to the block? What is the difference?
I see that #ensure: sends the message #valueNoContextSwitch instead of
#value, why not sending #valueNoContextSwitch instead of #valueEnsured then?
I see that #valueEnsured was suggested by @Martin McClure
<martin at hand2mouse.com> , Martin, could you explain the need for this
message? Thank you!!

And now, because I'm inconsistent (that is, human :-) ), I'm not sure
#valueEnsured has to keep the semantics of the return value of #ensure:, it
could not if there is a need for what you are suggesting.
Anyway, I'd like to understand why #valueEnsured is needed.

Cheers!
Hernan.



On Sun, Feb 26, 2023 at 8:34 AM Jaromir Matas via Cuis-dev <
cuis-dev at lists.cuis.st> wrote:

> Hi Juan, all,
>
>
>
> I’d expect this example return 1 instead of a block (for general usage);
> what do you think?
>
>
>
> [1] valueEnsured
>
>
>
> Enclosed is a suggestion how to make it return 1.
>
>
>
> Best,
>
> Jaromir
>
>
>
> --
>
> *Jaromír Matas*
>
> mail at jaromir.net
>
>
>
>
> --
> Cuis-dev mailing list
> Cuis-dev at lists.cuis.st
> https://lists.cuis.st/mailman/listinfo/cuis-dev
>


-- 

*Hernán WilkinsonAgile Software Development, Teaching & Coaching*
*Phone: +54-011*-4893-2057
*Twitter: @HernanWilkinson*
*site: http://www.10Pines.com <http://www.10pines.com/>*
Address: Alem 896, Floor 6, Buenos Aires, Argentina
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cuis.st/mailman/archives/cuis-dev/attachments/20230227/96569cca/attachment-0001.htm>


More information about the Cuis-dev mailing list