enum action : string
{
x = "test",
y = "test2",
z = "test3"
}
foreach (a; __traits(allMembers, action))
{
if (input == a)
{
return mixin("action." ~ a);
}
}
Why is /prog/ not using D? Why is *everyone* not using D?
Name:
Anonymous2012-01-26 14:10
can you explain this code? what does __traits do? what does mixin() do?
Name:
Anonymous2012-01-26 14:24
__traits returns a string array of all fields contained within action. A mixin is used to insert code at compile time; in this case it will evaluate to whatever field a currently points to. It's incredibly elegant and compact, whereas you can't even define an enum of strings in C++.
Name:
Anonymous2012-01-26 14:26
now do it in lisp, faggot
Name:
Anonymous2012-01-26 14:29
Who needs LISP when you have D?
Name:
Anonymous2012-01-26 14:39
Lisp > *
Name:
Anonymous2012-01-26 14:43
If D is a "new" C, why they still use ugly-as-fuck reserved words or functions with preceding underscores?
>>16
You can do the same in java but that doesn't make it any less shitty
Name:
Anonymous2012-01-27 9:50
I use C++ because... it's C for lazier people, and C is all ya you need.
Name:
Anonymous2012-01-27 10:07
>>20
This is moronic. C is not meant for high-level application, and it shows. Check out any popular web browser, music player, game, etc. written in C to see where you should not use this language. C is a portable assembly, and as such, should be limited to a low level environment where it belongs.
Embed a higher level language into C if you want abstraction and speed.
>>21 Check out any popular web browser, music player, game, etc. written in C to see where you should not use this language.
lol
Name:
Anonymous2012-01-27 11:03
>>19
Eliminating the overhead of the GC seems pretty non-shitty to me. Also, Java is shitty because it has an OOP stick up it's ass, and it runs on a VM. D has neither.