What do you thing about this string interpolation idea
    Martin Tschierschke 
    mt at smartdolphin.de
       
    Mon Dec 10 15:48:36 UTC 2018
    
    
  
On Monday, 10 December 2018 at 10:11:44 UTC, Daniel Kozak wrote:
> https://run.dlang.io/is/FbOnGI
>
> import std.stdio;
> template somefun()
> {
>      auto iterpolate(string s)()
>      {
>          //do some parsing
>          return mixin(s[1 .. $]);
>      }
> }
>
> enum enableInterpolate = "mixin somefun A; alias interpolate = 
> A.iterpolate;";
>
> void main()
> {
>     mixin(enableInterpolate);
>     int a = 5;
>     iterpolate!("$a").writeln;
> }
It is similar to my idea:
https://forum.dlang.org/post/uwbwjlmphpkllpeojjno@forum.dlang.org
(Where I define two functions mixinter(String)() and 
exho(string)()
to get a shorter expression when using scriptlike (dub package).)
So, yes very good :-)
    
    
More information about the Digitalmars-d
mailing list