typeof and my crummy code...
    div0 
    div0 at users.sourceforge.net
       
    Fri Nov  6 07:55:39 PST 2009
    
    
  
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Ellery Newcomer wrote:
> given tak.d:
> 
> import std.stdio;
> void main()
> {
> //int[1][2]([3][4] i[5][6])[7][8];
> 
>     int i(I)(int){return 1;}
>     writeln(typeof(i).stringof);
> }
> 
> $ dmd tak && ./tak
> 
> spits out 'void'
> 
> does this make sense, or would it make more sense as an error for not
> appending the template argument? Or would it make more sense to include
> the template parameter in the string?
> 
> OT: without looking at compiler output, what is the type of the
> commented out i in d-style? :)
I'm kinda leaning towards your code as being an error,
after all without a template argument i isn't anything at all.
Why you get void as the result I suppose.
Or perhaps it's an infinite set of functions.
c.f.:
import std.stdio;
string templatesAreOdd(alias b)() {
	return b.stringof;
}
void main() {
    int i(I)(int){return 1;}
    alias i!(int)	foo;
    writeln(typeof(foo)(2).stringof);
    writeln(templatesAreOdd!(i));
}
That gives you the i(I) you might have been expecting.
- --
My enormous talent is exceeded only by my outrageous laziness.
http://www.ssTk.co.uk
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iD8DBQFK9Eb7T9LetA9XoXwRArMmAJ9MnTVHtDLM52w0JUf0wzfAXHqfSACfWti3
pZPsQhpk9f0C0DDGlQOAu/c=
=L6SH
-----END PGP SIGNATURE-----
    
    
More information about the Digitalmars-d-learn
mailing list