Hi all,
I have just read Walter's article about octals on Dr. Dobb's. As a newbie, I tried to create one myself.

template octal(int n) {
        int toOct(int x) {...}
        
        enum octal = toOct(n);
}

void main() {
        import std.stdio : writeln;
        writeln(octal!10);
}

I have two questions about this.
1) The specification is clear that the if the template has only one member and the member has the same name with the template's, the member is implicitly referred to in the instantiation. The template octal has two members, so the program should not really be compiling, and yet it does. Is this a compiler bug? 2) I chose the declare the inner "octal" as an enum following Walter's example. But why enum? What would be different if it were auto, immutable, or static?

Thanks guys!
Michael

Reply via email to