[Issue 1903] New: Template declaration (for mixin) can't be parsed

Russell Lewis webmaster at villagersonline.com
Mon Mar 10 15:11:45 PDT 2008


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.


More information about the Digitalmars-d-bugs mailing list