What type functions mean on a language level
sighoya
sighoya at gmail.com
Wed Jan 6 13:56:37 UTC 2021
On Wednesday, 6 January 2021 at 13:20:35 UTC, Jacob Carlborg
wrote:
>In my idea for AST macros, there would be support for
>quasi-quoting and splicing. >It's implemented as a built-in
>function that converts the internal AST (defined in the
>compiler) to the external AST (defined in druntime).
>ast(f(a, b)); // single line
>ast({ // multiple statements
> int a = 3;
> int b = 4;
> f(a, b);
>});
>auto name = ast(a);
>ast({
> int $name = 3; // splicing. This will declare a variable
> with the name "a"
>});
Reminds me on Scala macros.
Yes it would be nice, but is it likely to get them in D?
If we're allowed to read any source code from our project, we
could write our own macro framework to parse strings of code
though the work is doubled as they have to be expanded and
re-parsed again by the compiler.
More information about the Digitalmars-d
mailing list