How does laziness and UFCS interact?
John Colvin via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Tue Mar 10 08:00:45 PDT 2015
On Tuesday, 10 March 2015 at 14:41:00 UTC, Logan Capaldo wrote:
> On Monday, 9 March 2015 at 22:15:43 UTC, Ali Çehreli wrote:
>> You are right. I had the same observation at minute 11:27
>> below, where I warn against UFCS with assumeWontThrow:
>>
>>
>> http://www.youtube.com/watch?feature=player_detailpage&v=oF8K4-bieaw#t=687
>>
>> Ali
>
> Sorry, which is right? I know ifThrown is lazy, I'm curious
> about the "amount" of the expression that is evaluated lazily.
>
>
> a.b().c().assumeWontThrow vs. a.b().c().assumeWontThrow
> ^--+----^ ^-^
> | |
> +- lazy? +- lazy?
>
>
> The video seems to say "don't use lazy functions with UFCS
> because you might think the lazy part gets evaluated first,
> when it does not". Seems reasonable, although I don't know it's
> any different than assumeWontThrow(f()).
a.b().c().assumeWontThrow is rewritten as
assumeWontThrow(a.b().c()) and therefore the whole chain is lazy.
More information about the Digitalmars-d-learn
mailing list