Thread overview
Template alias parameters
Aug 01, 2005
Vathix
Aug 01, 2005
Vathix
Aug 01, 2005
Vathix
August 01, 2005
Why can't a local variable be passed to a template's alias parameter? Because of something like this?:

   template Foo(alias X)
   {
      static int* p = &X;
   }

If so, shouldn't this restriction be up to the programmer? How about adding feature "static alias" to enforce no local variables, and regular alias would allow them..? It seems like never allowing locals is a big limitation.
August 01, 2005
On Mon, 01 Aug 2005 01:39:24 -0400, Vathix <chris@dprogramming.com> wrote:

> Why can't a local variable be passed to a template's alias parameter?

I guess I understand why now, but I don't know why this won't work:

   template Templ(alias val)
   {
      int Templ = val;
   }

   int cow = 3324;
   int main()
   {
      writefln(Templ!(cow));
      return 0;
   }

DMD 0.128 says "non-constant expression cow".
August 01, 2005
nevermind, I got it.