On 3/30/11 9:45 PM, KennyTM~ wrote:
On Mar 31, 11 03:28, Ary Manzana wrote:
I think :: is not used in the language.
In a recent article about D I saw:
mixin(__traits(identifier, T) ~ " " ~
to!string(tolower(__traits(identifier, T)[0])) ~
__traits(identifier, T)[1..$] ~ ";");
What if foo::bar were an alias for __traits(foo, bar) ?
The code would look like this:
mixin(T::identifier ~ " " ~
to!string(tolower(T::identifier[0])) ~
T::identifier[1..$] ~ ";");
What do you think?
Another uses:
__traits(int, isArithmetic) ==> int::isArithmetic
__traits(C, isAbstractClass) ==> C::isAbstractClass
You've got the order wrong.
__traits(hasMember, S, "m") ==> S::hasMember("m")
Well, you get the idea...
:: might be applied to other compile time uses, but I just came up with
this...
-1.
This is confusing as :: is used to separate scopes in C++ (and PHP too).
e.g.
struct A {
int x;
bool isSame(const A other) pure const { return x == other.x; }
}
void main () {
A a = A(2), b = A(2);
assert ( a.isSame(b)); // ok
assert (! a::isSame(b)); // ???
}
(How about that 'meta' namespace proposal? meta.hasMember(S, "m") )
I think think this is a valid reason. D does many things differently
than C++. I don't know how many times I heard someone complaining about
D's lack of struct inheritance.
--
/Jacob Carlborg