Is there any hope for "lazy" and @nogc?
Shachar Shemesh
shachar at weka.io
Wed Aug 1 07:59:22 UTC 2018
Thank you! Finally!
Let me just state, for the record, that having *yet another* syntax
special case is just appalling.
With that said, I was hoping that specifying it explicitly as a delegate
would allow me to scope it. Apparently, that doesn't work :-(
Shachar
On 31/07/18 23:03, ag0aep6g wrote:
> On 07/31/2018 09:17 AM, Shachar Shemesh wrote:
>> I'm trying to figure out what's the signature of the built-in assert.
>> It does not seem that I can define a similar function myself.
>
> Looks like you can do it with a "lazy variadic function" [1], but it's
> not pretty:
>
> ----
> alias Dg = string delegate() @nogc nothrow;
>
> void myAssert(bool cond, Dg[1] msg_dg ...) @nogc nothrow
> {
> import core.stdc.stdio;
> if (!cond)
> {
> string msg = msg_dg[0]();
> printf("%*s\n", msg.length, msg.ptr);
> }
> }
> ----
>
> [1] https://dlang.org/spec/function.html#lazy_variadic_functions
More information about the Digitalmars-d
mailing list