[Issue 6207] New: Mixin template evaluated to string can convert to string mixin expression implicitly
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Fri Jun 24 03:53:18 PDT 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6207
Summary: Mixin template evaluated to string can convert to
string mixin expression implicitly
Product: D
Version: D2
Platform: All
OS/Version: All
Status: NEW
Severity: enhancement
Priority: P2
Component: DMD
AssignedTo: nobody at puremagic.com
ReportedBy: k.hara.pg at gmail.com
--- Comment #0 from Kenji Hara <k.hara.pg at gmail.com> 2011-06-24 03:48:28 PDT ---
If mixin template instantiation makes manifest constant string and it appears
in expression context, the compiler converts it implicitly to string mixin
expression.
This enhancement feature does not conflict with any existing features.
Because normal instantiating with mixin template is illegal.
Sample code:
----
mixin template expand(string code)
{
static if (code.length >= 2 && code[0..2] == "$x")
{
enum expand = `x` ~ code[2..$];
pragma(msg, expand);
}
else
enum expand = code;
}
void main()
{
int x = 1;
int y = expand!q{$x+2};
// Rhs is implicitly converted to mixin(expand!(q{$x+2}))
assert(y == 3);
}
----
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list