[Issue 1903] New: Template declaration (for mixin) can't be parsed
Robert Fraser
fraserofthenight at gmail.com
Mon Mar 10 16:20:55 PDT 2008
Russell Lewis wrote:
> downs wrote:
>> d-bugmail at puremagic.com wrote:
>>> http://d.puremagic.com/issues/show_bug.cgi?id=1903
>>>
>>> Summary: Template declaration (for mixin) can't be parsed
>>> Product: D
>>> Version: 2.012
>>> Platform: PC
>>> OS/Version: Linux
>>> Status: NEW
>>> Severity: normal
>>> Priority: P2
>>> Component: DMD
>>> AssignedTo: bugzilla at digitalmars.com
>>> ReportedBy: webmaster at villagersonline.com
>>>
>>>
>>> DMD 2.012 Linux
>>>
>>> The following code doesn't work, and if I understand correctly, it
>>> should:
>>>
>>> BEGIN CODE
>>>
>>> void Foo(int a,int b) {}
>>> template Bar(int x)
>>> {
>>> Foo(x,x);
>>> }
>>> void Baz()
>>> {
>>> mixin Bar!(1);
>>> }
>>>
>>> END CODE
>>>
>>>
>>
>> The problem is that a template basically constitutes a namespace, not
>> a scope. :)
>>
>> So you can only put stuff in a template that you could also put at the
>> global module level.
>>
>> --downs
>
> I refactored it to use string mixins. It works now, but it's ugly.
Well, AST macros are a planned feature. In fact, there's already a
macro.c in DMD2's front-end source code :-).
More information about the Digitalmars-d-bugs
mailing list