Why callers should explicitly document storage classes
Timon Gehr
timon.gehr at gmx.ch
Sun Aug 14 14:20:12 PDT 2011
On 08/14/2011 10:36 PM, Jonathan M Davis wrote:
> On Sunday, August 14, 2011 22:25:36 Timon Gehr wrote:
>> On 08/14/2011 10:00 PM, Vladimir Panteleev wrote:
>>> On Sun, 14 Aug 2011 22:48:18 +0300, Timon Gehr<timon.gehr at gmx.ch> wrote:
>>>> requiring lazy before lazy arguments basically destroys the reason for
>>>> lazy being in the language:
>>>>
>>>> int foo(lazy 2*3);
>>>>
>>>> is not better than
>>>>
>>>> int foo({return 2*3});
>>>
>>> What about requiring "lazy" only for non-pure delegates?
>>
>> Actually I would rather require lazy arguments to be pure, so that they
>> can be guaranteed to be executed at most once.
>
> That still wouldn't be guaranteed, since pure function calls are only
> optimized out if they're strongly pure and in the same expression. You can't
> rely on calls to pure functions being optimized.
>
> - Jonathan M Davis
My point was, that if lazy arguments were required to be pure, such a
thing _could_ then be guaranteed independently from optimizations that
may or may not take place on general pure functions.
More information about the Digitalmars-d
mailing list