Multiple Specialization?

BCS BCS at pathilink.com
Sat Dec 23 08:17:37 PST 2006


Paul Findlay wrote:
 > This is an idea I had one walk.. using something like a static switch.
[...]
 > a static switch version:
 >
 >
 > public int write(T)(MDState s)
 > {
 >     MDFile i = cast(MDFile)s.getInstanceParam(0, this);
 >
 >     T val;
 >
 >     static switch(T) {
 >     case(ubyte): case(ushort): case(int):
 >         val = s.getIntParam(1);
 >         break;
 >     case(float):
 >         val = s.getFloatParam(1);
 >         break;
 >     case(char): case(wchar): case(dchar):
 >         val = s.getCharParam(1);
 >         break;
 >     }
 > //.. snip
 >
 >     return 0;
 > }
 >
 > and I imagined having static switch and case been able to handle type
 > tuples if for example the function prototype was
 >
 > public int write(T...)(MDState s)
 > // no example because I am lazy
 >
 > Does this make sense?
 >
 >  - Paul

Yes

I was thinking of posting about the same concept my self. (I second the 
ides)



More information about the Digitalmars-d mailing list