On 03/30/2011 09: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.
D is not C++. D precisely exists to make things differently, ie its own way.
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") )
This is no improvement about __traits. I'm all for a meta namespace, but it
should be syntactically attractive. There is no contradiction between Ary's
proposal meta, though the exact optimal syntax may not be that one.
Denis
--
_________________
vita es estrany
spir.wikidot.com