[Cuis-dev] #valueEnsured return value

Juan Vuletich juan at cuis.st
Tue Feb 28 10:19:34 PST 2023


I think it would be consistent to make it answer the value of the 
evaluation of the receiver. Doesn't seem important, though.

Thanks,

On 2/27/2023 10:04 AM, Jaromir Matas via Cuis-dev wrote:
>
> Hi Hernan,
>
> Thanks for your msg. I’m AFK so briefly: At least one critical use of 
> valueEnsured (or [] ensure: aBlock) is in #terminate. We need to make 
> sure the receiver is evaluated even if the process is terminated. 
> Replacing it with #value will show you which test will fail :)
>
> Yes, it may be understood as a mere shortcut as you wrote but I’m 
> thinking it may as well get another semantics, which is: Evaluate the 
> receiver no matter what and return the block’s return value. In 
> terminate I don’t need the return value but in general it may make sense.
>
> Any opinions welcome; although I’m aware this has rather rare use :)
>
> Thanks again,
>
> Jaromir
>
> *From: *Hernán Wilkinson <mailto:hernan.wilkinson at 10pines.com>
> *Sent: *Monday, February 27, 2023 13:18
> *To: *Discussion of Cuis Smalltalk <mailto:cuis-dev at lists.cuis.st>; 
> Martin McClure <mailto:martin at hand2mouse.com>
> *Cc: *juan at cuis.st <mailto:juan at cuis.st>; Jaromir Matas 
> <mailto:mail at jaromir.net>
> *Subject: *Re: [Cuis-dev] #valueEnsured return value
>
> 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 
> <mailto: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 <mailto: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 <mailto:mail at jaromir.net>
>
>     -- 
>     Cuis-dev mailing list
>     Cuis-dev at lists.cuis.st <mailto:Cuis-dev at lists.cuis.st>
>     https://lists.cuis.st/mailman/listinfo/cuis-dev
>
>
>
> -- 
> *Hernán Wilkinson
> Agile 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


-- 
Juan Vuletich
cuis.st
github.com/jvuletich
researchgate.net/profile/Juan-Vuletich
independent.academia.edu/JuanVuletich
patents.justia.com/inventor/juan-manuel-vuletich
linkedin.com/in/juan-vuletich-75611b3
twitter.com/JuanVuletich

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cuis.st/mailman/archives/cuis-dev/attachments/20230228/1ef42aca/attachment.htm>


More information about the Cuis-dev mailing list