use template function without assignment
Ali Çehreli
acehreli at yahoo.com
Tue Jul 30 13:34:32 PDT 2013
On 07/30/2013 12:09 PM, JS wrote:
> I already stated why this is not a proper example, I'm not using Pragma
> in run time code(for lack of a better term).
>
> module main;
>
> import std.stdio;
>
>
> template Pragma(alias amsg)
> {
> void Pragma(string file = __FILE__)
> {
> pragma(msg, amsg);
> }
> }
>
> template t()
> {
> Pragma!("help, this does not work!!!!!!!!!");
> }
>
> void main()
> {
> enum msg = "hello";
> Pragma!msg;
> t!();
> }
Thank you. Now we have something to work on. The program above produces
the following error:
Error: no identifier for declarator Pragma!"help, this does not
work!!!!!!!!!"
The error is fixed by adding a mixin:
mixin Pragma!("help, this does not work!!!!!!!!!");
Despite another error it actually works:
hello
help, this does not work!!!!!!!!! <-- IT WORKED
Error: t!() has no effect
The second error is fixed by another mixin:
mixin t!();
Perhaps the example is too simplistic. Still, let's stay with it for
further issues.
Ali
More information about the Digitalmars-d-learn
mailing list