Difference (last change) (no other diffs, normal page display)
On important point, if you don't instantiate your template, the compiler will not tell you if the template compiles or not (only syntactic checks are done).|
An important point: if you don't instantiate your template, the compiler will not tell you if the template compiles or not (only syntactic checks are done).|
This is going to start as a quick notes page, and may never evolve into a well formed page. These notes will be from a port of Juno and anything that comes to mind while writing it. This is also written for Phobos -> Phobos and will not provide advice about where to get Tango library features.
An important point: if you don't instantiate your template, the compiler will not tell you if the template compiles or not (only syntactic checks are done).
See also D 2.0 Specific Features.
One of the major changes in D is how const works. Const is transitive and is intended to support immutable. And with that change the string alias was updated to
This means you can modify the array, but not its contents. In the case that you are modifying the content you'll want to change string to char. In other situations you'll need to make different choices depending on what you are doing.
Functions should take a const, or in as this allows the function to take mutable and immutable data. Unless the parameter is going to be change. But returning from a function you'll want to go with immutable if at all possible, usually if returning a char.
Use of \n outside of quotes is no longer valid, use "\n".
The this reference is now a value type inside structs, be sure to remove any dereferences *this -> this and add references this -> &this
Operators no longer have their own overload function named after them. Instead there are functions for "types" of overloading, such as opBinary/opUnary. This is one area where it is simpler not to forward to your existing functions and write it with the new system in mind. I won't go into details, but leave you with this commit.
Phobos has changed some function names to be consistent with a standard, for example tolower() is now toLower(). I won't give a full list but here is some off the top of my head.
And others got templatized:
Note that templates when passed a single parameter, parentheses are not required.
With the introduction of ranges there are changes to how some functions operate.
std.string.find has been replaced by std.algorithm.find and does not return an index, instead it will return the range advanced to that location. If you wish to see if you found an element check
The compiler now finds more problems or potential problems in code.
Control flow is required in switch statements.
There are others just can't remember them.