What is :-) ?

evilrat evilrat666 at gmail.com
Mon Nov 20 10:22:38 UTC 2023


On Monday, 20 November 2023 at 09:44:32 UTC, Antonio wrote:
>
> - Why writeln doesn't treat ```next``` and ```Counter``` the 
> same way?  (I think I understand why, but it shows a "low" 
> level difference of something that syntactically is equivalent)
>
> - What is the way to show Counter signature using ```writeln``` 
> (if possible)?
>

I found no way to tell compiler that I don't want to call Counter 
and instead want to take the function itself, but closest thing 
is just to take the string representation at compile time (same 
as used in pragma msg) and pass it to writeln instead of Counter.

I guess this is one of these bif oof moments with UFCS, a 
function returning a (parameterless) function.

Note that in most cases you should never make runtime decisions 
on .stringof value as it is not standardized.


```
//pragma(msg, typeof(Counter)); // pure nothrow @safe int 
delegate() pure nothrow @nogc @safe(int nextValue)
enum f = typeof(Counter).stringof; // same string as above
writeln( "'Counter' is ", f);
```

Of course this works too
`writeln( "'Counter' is ", typeof(Counter).stringof);`




More information about the Digitalmars-d-learn mailing list