Source expression passed to a lazy parameter

Basile B. b2.temp at gmx.com
Mon Apr 9 08:54:21 UTC 2018


On Monday, 9 April 2018 at 08:27:50 UTC, Per Nordlöw wrote:
> Is it possible to get the source expression sent to a lazy 
> function?
>
> So that I can implement something like
>
> show(Arg)(lazy Arg arg)
> {
>     writeln(arg.sourceof, arg);
> }
>
> used as
>
>     show(1+2+3);
>
> will print
>
>     1+2+3:6

No (afaik), what you need is an internal compiler function, 
"toChars" IIRC, that's available for each node.


More information about the Digitalmars-d-learn mailing list