Good Evening,
As you know from my previous typefunction project I am trying to make CTFE more usable for proper metaprogramming (as opposed to just string manipulation and string mixins).
Since I do believe that working with structure and rich data-types is more useful than working with only strings essentially.
The goal is to be able to write regular procedural code, to introspect existing or generate new code.
This I want to achieve with core.reflect and core.codegen, which will be part of druntime and give access to compiler/CTFE integrated reflection capabilities.
in core.reflect.decl, for example you would see:
import core.reflect.node; // Empty base class is defined in there
enum DeclarationKind
{
FunctionDeclatation,
/+
StructDeclaration,
UnionDeclarartion,
ClassDeclarartion,
VariableDeclaration,
AliasDeclaration,
TemplateDeclaration,
+/
}
class Declaration : Node
{
string name;
DeclarationKind kind;
Attribute[] attributes;
Linkage linkage;
string comment;
}
Declaration[] DeclarationsFromString(string s);
Which can then be used like so:
pragma(msg, DeclarationsFromString(
q{
int var = 3;
void* myFunc (void*) {};
}
)[1].name);
and it would output the name if the second Declarartion which is:
"myFunc"
this functionality does already work as of a few hours ago.
However it runs into forward reference issues even more than type functions did.
And I assume I'll first have to make advances on dealing with complicated forward reference graphs before I can show anything neat.