mixin troubles

Derek Parnell derek at psyc.ward
Thu Oct 5 16:04:05 PDT 2006


On Thu, 05 Oct 2006 14:28:01 -0500, Josh Stern wrote:

> I think the double use of "Foo" for the template namespace and the
> function itself made the example confusing.  The following works
> and makes the role of the template and the function and/or class
> names clearer (no alias really needed):

I think you have missed my point.

I want to mixin the template multiple times, each time giving the resulting
statement a different identifier so it can be used in a simple manner. For
example, using your 'different' name idea ...

 import std.stdio;
 template FFoo(alias b) {
  typeof(b) foo() { return b; } // foo function
 }
 void main() {
  int a=5;
  double b = 3.14;
  // FIRST TIME
  mixin .FFoo!(a) x;  // bring in the statement calling it 'x'
  writefln( x() );
  // SECONND TIME
  mixin .FFoo!(b) y;  // bring it in again but call it 'y' this time.
  writefln( y() );
 }


This still fails and yet looks intuitive (to me at least).


-- 
Derek Parnell
Melbourne, Australia
"Down with mediocrity!"



More information about the Digitalmars-d-learn mailing list