-
-
Notifications
You must be signed in to change notification settings - Fork 98
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Mixin Template Intermediary Storage #237
base: master
Are you sure you want to change the base?
Conversation
Want some feedback if something is a bit hazy or help if you can make it clearer
File needs a |
It took me a while to understand what the DIP was trying to solve, but I now I understand: it's about how mixin templates by nature don't have lexical scoping, so you can't declare temporaries into them since those would get mixed in along with the rest. The abstract talking about "without making it get included in the code generation" made me think it was about the backend / those symbols not appearing in the resulting binary. I think making it a visibility attribute ( Some links to real code using workarounds for this problem would be helpful both for motivation and understanding of the DIP. |
Yea, I thought about the Real code examples are a bit verbose, so I thought they would not fit in a DIP. I have some like that, notice that I'm doing mixin template HipExportDFunctions(alias mod)
{
import std.traits:getSymbolsByUDA, ParameterIdentifierTuple;
pragma(msg, "Exporting ", mod.stringof);
static foreach(mem; __traits(allMembers, mod))
{
//Currently only supported on classes and structs
static if( (is(mixin(mem) == class) || is(mixin(mem) == struct) ))
{
mixin HipExportDFunctionsImpl!(mem, mixin(mem));
}
}
} |
Change from mixin delete to mixin private
I think that the goal of the DIP is not well defined. It is about adding a new storage class to prevent clashes in This is why it is a bit hard to understand for now. A better introductionary example would be before:
static foreach(mem; __traits(allMembers, A))
{
// this fails for now, because the symbol already exists for b
alias member = __traits(getMember, A, mem);
}
struct A
{
int b;
int c;
}
after:
static foreach(mem; __traits(allMembers, A))
{
// works now:
// "mixin private" scope creates a symbol whose
// lifetime & scope are limted to an iteration
mixin private alias member = __traits(getMember, A, mem);
}
struct A
{
int b;
int c;
} That get rid of the confusion created by the mixin templates. Alos since it's clear now that it's not about mixins,maybe that another syntax would make more sense. |
@SixthDot While redefinition within a The DIP would make any definitions exposed via a If we were designing the language today, one could even argue that That would allow for such things as using |
Want some feedback if something is a bit hazy or help if you can make it clearer