Is there any hope for "lazy" and @nogc?

Iain Buclaw ibuclaw at gdcproject.org
Fri Aug 3 21:53:33 UTC 2018


On 2 August 2018 at 16:14, Seb via Digitalmars-d
<digitalmars-d at puremagic.com> wrote:
> On Wednesday, 1 August 2018 at 20:32:11 UTC, Iain Buclaw wrote:
>>
>> On 1 August 2018 at 18:52, Shachar Shemesh via Digitalmars-d
>> <digitalmars-d at puremagic.com> wrote:
>>>
>>> [...]
>>
>>
>> My first thought was to have a look at enforce(), but on closer
>> observation it is neither @nogc or nothrow.
>>
>> Maybe you should raise a bug report?
>>
>> It's certainly worth an attempt to bridge these two features together. I
>> think it makes sense enough that lazy parameters should infer attributes
>> from the function, and that it should be an error to pass a parameter that
>> does not meet those constraints.
>>
>> i.e:
>> ---
>> // Signatures.
>> void myAssert(bool cond, lazy string msg) @nogc nothrow;
>> string mayAlloc() nothrow;
>> string mayThrow() @nogc;
>>
>> // Code
>> myAssert(cond, mayAlloc());    // violates @nogc
>> myAssert(cond, mayThrow());    // violates nothrow
>> ---
>>
>> Iain.
>
>
> Isn't this https://issues.dlang.org/show_bug.cgi?id=12647?

Seems so, good to know.  I'll bookmark it for when I get time to do
other things.

Iain.


More information about the Digitalmars-d mailing list