Is it possible to use templates to implement something like the `@show` macro from the Julia programming langauge in D?

Paul Backus snarwin at gmail.com
Mon Sep 9 00:35:08 UTC 2024


On Sunday, 8 September 2024 at 23:01:22 UTC, monkyyy wrote:
> On Sunday, 8 September 2024 at 22:01:10 UTC, WraithGlade wrote:
>> I want to just be able to write this:
>>
>> ```
>> show!(1 + 2)
>> ```
>
> ```d
> void show(string s)(){
>   auto res=mixin(s);
>   writeln(s,"==",res);
> }
>
> show!"1+2";
> ```

This works for `show!"1+2"`, but it won't work for `show!"x"`, 
because `x` is not visible inside the body of the `show` function.


More information about the Digitalmars-d-learn mailing list