Changes for newer version...

Timon Gehr timon.gehr at
Fri Jan 20 13:48:43 PST 2012

On 01/19/2012 09:30 PM, Era Scarecrow wrote:
>   Been a bit out of it for a while, but finding enough tools at my disposal I feel I can work on/convert a project now.
>   I happen to have one of the first printing books (without the name on the cover), and although it may be worth millions in a few years, apparently there's been enough changes that certain features are not familiar in the discussions.
>   So I need to ask since I don't see any obvious pages that describe it. What are the changes to D2, since the book's release? What has externally changed? (Internal implementation of features need not be mentioned if it's transparent to the programmer and user).

The most important changes are probably:

- inout type qualifier

The type qualifier inout can be used as a wildcard to stand for any of 
mutable, const, immutable. Its meaning is automatically deduced and is 
the same throughout a certain function definition or function call.

For example:

inout(int)[] identity(inout(int)[] x){return x;}
int[] x;
immutable(int)[] y;
const(int)[] z;
static assert(is(typeof(identity(x)) == int[]));
static assert(is(typeof(identity(y)) == immutable(int)[]));
static assert(is(typeof(identity(z)) == const(int)[]));

- function local imports
void main(){
     import std.stdio;
     writeln("hello world!");

- new function/delegate literal syntax (coming DMD 2.058)

identifier => expression
(id1, id2) => expression
(type id1, type id2) => expression

import std.stdio, std.range, std.algorithm;
void main(){
     writeln("some odd squares:");

More information about the Digitalmars-d-learn mailing list