Switching from Java to D: Beginner questions, multiplatform issues, etc.

Simon Bürger" <simon.buerger at rwth-aachen.de> Simon Bürger" <simon.buerger at rwth-aachen.de>
Thu Feb 27 14:55:31 PST 2014


> What exactly is the difference between C and D headers?
D itself does not use headers at all. But you will need "D 
headers", if you want to call a C library from D. The translation 
is mostly syntatic and straight forward like:
* replace #define-constants with enums
* replace macros with (templated) functions
* replace #ifdef with static-if / version
etc...


> Metaprogramming is always welcomed; makes things much easier in 
> the long run.
> I'll probably find this out on my own eventually, but does D 
> support operator overloading? That would be simply amazing.
Absolutely it does. Even in a more "meta"-way than c++:

struct S
{
     int x;
     S opBinary(string op)(S other) // overloads + - * / % all at 
once
     {
           return mixin("x "~op~" other.x");
     }
}


More information about the Digitalmars-d-learn mailing list