Fudcon D programming

Post on 04-Jul-2015

263 views 1 download

Transcript of Fudcon D programming

D Programming

Jonathan MERCIER

IntroductionObject

Functional

Meta-programming

Parallelism

Ressource Management

Contract

System and Safe Code

Reference and pointer

Generics

Inference

Loops

Functions

Debugs

Versions

Requirement

Editors

BasicsMy first D program

Types

Arrays

String and characters

Const and Immutable

Input/Output

Algorithm

Structure and Class

Template

Miscellanous

Let start it!

GTK D

Thanks To

.

......

D ProgrammingIn nutshell

Jonathan MERCIER

December 9, 2012

. .. 1/122.

D Programming .

.

.. . . Forward

D Programming

Jonathan MERCIER

IntroductionObject

Functional

Meta-programming

Parallelism

Ressource Management

Contract

System and Safe Code

Reference and pointer

Generics

Inference

Loops

Functions

Debugs

Versions

Requirement

Editors

BasicsMy first D program

Types

Arrays

String and characters

Const and Immutable

Input/Output

Algorithm

Structure and Class

Template

Miscellanous

Let start it!

GTK D

Thanks To

Plan.....1 Introduction

ObjectFunctionalMeta-programmingParallelismRessource ManagementContractSystem and Safe CodeReference and pointerGenericsInferenceLoopsFunctionsDebugsVersionsRequirementEditors

...2 BasicsMy first D programTypesArraysString and charactersConst and ImmutableInput/OutputAlgorithmStructure and ClassTemplateMiscellanousLet start it!

...3 GTK D

...4 Thanks To. .. 2/122. .. 2/122.

D Programming .

.

.. . . Forward.

.

. ... Back

D Programming

Jonathan MERCIER

IntroductionObject

Functional

Meta-programming

Parallelism

Ressource Management

Contract

System and Safe Code

Reference and pointer

Generics

Inference

Loops

Functions

Debugs

Versions

Requirement

Editors

BasicsMy first D program

Types

Arrays

String and characters

Const and Immutable

Input/Output

Algorithm

Structure and Class

Template

Miscellanous

Let start it!

GTK D

Thanks To

Before starting

. .. 3/122. .. 3/122.

D Programming .

.

.. . . Forward.

.

. ... Back

D Programming

Jonathan MERCIER

IntroductionObject

Functional

Meta-programming

Parallelism

Ressource Management

Contract

System and Safe Code

Reference and pointer

Generics

Inference

Loops

Functions

Debugs

Versions

Requirement

Editors

BasicsMy first D program

Types

Arrays

String and characters

Const and Immutable

Input/Output

Algorithm

Structure and Class

Template

Miscellanous

Let start it!

GTK D

Thanks To

Why a new language?

.Few significant dates..

......

C++ 1983

Java 1990Python 1995Ruby 1995

And now?

. .. 4/122. .. 4/122.

D Programming .

.

.. . . Forward.

.

. ... Back

D Programming

Jonathan MERCIER

IntroductionObject

Functional

Meta-programming

Parallelism

Ressource Management

Contract

System and Safe Code

Reference and pointer

Generics

Inference

Loops

Functions

Debugs

Versions

Requirement

Editors

BasicsMy first D program

Types

Arrays

String and characters

Const and Immutable

Input/Output

Algorithm

Structure and Class

Template

Miscellanous

Let start it!

GTK D

Thanks To

Why a new language?

.Few significant dates..

......

C++ 1983Java 1990

Python 1995Ruby 1995

And now?

. .. 4/122. .. 4/122.

D Programming .

.

.. . . Forward.

.

. ... Back

D Programming

Jonathan MERCIER

IntroductionObject

Functional

Meta-programming

Parallelism

Ressource Management

Contract

System and Safe Code

Reference and pointer

Generics

Inference

Loops

Functions

Debugs

Versions

Requirement

Editors

BasicsMy first D program

Types

Arrays

String and characters

Const and Immutable

Input/Output

Algorithm

Structure and Class

Template

Miscellanous

Let start it!

GTK D

Thanks To

Why a new language?

.Few significant dates..

......

C++ 1983Java 1990Python 1995

Ruby 1995

And now?

. .. 4/122. .. 4/122.

D Programming .

.

.. . . Forward.

.

. ... Back

D Programming

Jonathan MERCIER

IntroductionObject

Functional

Meta-programming

Parallelism

Ressource Management

Contract

System and Safe Code

Reference and pointer

Generics

Inference

Loops

Functions

Debugs

Versions

Requirement

Editors

BasicsMy first D program

Types

Arrays

String and characters

Const and Immutable

Input/Output

Algorithm

Structure and Class

Template

Miscellanous

Let start it!

GTK D

Thanks To

Why a new language?

.Few significant dates..

......

C++ 1983Java 1990Python 1995Ruby 1995

And now?

. .. 4/122. .. 4/122.

D Programming .

.

.. . . Forward.

.

. ... Back

D Programming

Jonathan MERCIER

IntroductionObject

Functional

Meta-programming

Parallelism

Ressource Management

Contract

System and Safe Code

Reference and pointer

Generics

Inference

Loops

Functions

Debugs

Versions

Requirement

Editors

BasicsMy first D program

Types

Arrays

String and characters

Const and Immutable

Input/Output

Algorithm

Structure and Class

Template

Miscellanous

Let start it!

GTK D

Thanks To

Why a new language?

.Few significant dates..

......

C++ 1983Java 1990Python 1995Ruby 1995

And now?

. .. 4/122. .. 4/122.

D Programming .

.

.. . . Forward.

.

. ... Back

D Programming

Jonathan MERCIER

IntroductionObject

Functional

Meta-programming

Parallelism

Ressource Management

Contract

System and Safe Code

Reference and pointer

Generics

Inference

Loops

Functions

Debugs

Versions

Requirement

Editors

BasicsMy first D program

Types

Arrays

String and characters

Const and Immutable

Input/Output

Algorithm

Structure and Class

Template

Miscellanous

Let start it!

GTK D

Thanks To

What is D programming?

D is a modern language programming inspired by:C++JavaHaskellPythonRuby

. .. 5/122. .. 5/122.

D Programming .

.

.. . . Forward.

.

. ... Back

D Programming

Jonathan MERCIER

IntroductionObject

Functional

Meta-programming

Parallelism

Ressource Management

Contract

System and Safe Code

Reference and pointer

Generics

Inference

Loops

Functions

Debugs

Versions

Requirement

Editors

BasicsMy first D program

Types

Arrays

String and characters

Const and Immutable

Input/Output

Algorithm

Structure and Class

Template

Miscellanous

Let start it!

GTK D

Thanks To

Why a new language?

.D Combines..

......

Modeling Power

Modern ConvenienceNative Efficiency

. .. 6/122.. .. 6/122.

D Programming .

.

.. . . Forward.

.

. ... Back

D Programming

Jonathan MERCIER

IntroductionObject

Functional

Meta-programming

Parallelism

Ressource Management

Contract

System and Safe Code

Reference and pointer

Generics

Inference

Loops

Functions

Debugs

Versions

Requirement

Editors

BasicsMy first D program

Types

Arrays

String and characters

Const and Immutable

Input/Output

Algorithm

Structure and Class

Template

Miscellanous

Let start it!

GTK D

Thanks To

Why a new language?

.D Combines..

......

Modeling PowerModern Convenience

Native Efficiency

. .. 6/122.. .. 6/122.

D Programming .

.

.. . . Forward.

.

. ... Back

D Programming

Jonathan MERCIER

IntroductionObject

Functional

Meta-programming

Parallelism

Ressource Management

Contract

System and Safe Code

Reference and pointer

Generics

Inference

Loops

Functions

Debugs

Versions

Requirement

Editors

BasicsMy first D program

Types

Arrays

String and characters

Const and Immutable

Input/Output

Algorithm

Structure and Class

Template

Miscellanous

Let start it!

GTK D

Thanks To

Why a new language?

.D Combines..

......

Modeling PowerModern ConvenienceNative Efficiency

. .. 6/122.. .. 6/122.

D Programming .

.

.. . . Forward.

.

. ... Back

D Programming

Jonathan MERCIER

IntroductionObject

Functional

Meta-programming

Parallelism

Ressource Management

Contract

System and Safe Code

Reference and pointer

Generics

Inference

Loops

Functions

Debugs

Versions

Requirement

Editors

BasicsMy first D program

Types

Arrays

String and characters

Const and Immutable

Input/Output

Algorithm

Structure and Class

Template

Miscellanous

Let start it!

GTK D

Thanks To

Plan.....1 Introduction

ObjectFunctionalMeta-programmingParallelismRessource ManagementContractSystem and Safe CodeReference and pointerGenericsInferenceLoopsFunctionsDebugsVersionsRequirementEditors

...2 BasicsMy first D programTypesArraysString and charactersConst and ImmutableInput/OutputAlgorithmStructure and ClassTemplateMiscellanousLet start it!

...3 GTK D

...4 Thanks To. .. 7/122.. .. 7/122.

D Programming .

.

.. . . Forward.

.

. ... Back

D Programming

Jonathan MERCIER

IntroductionObject

Functional

Meta-programming

Parallelism

Ressource Management

Contract

System and Safe Code

Reference and pointer

Generics

Inference

Loops

Functions

Debugs

Versions

Requirement

Editors

BasicsMy first D program

Types

Arrays

String and characters

Const and Immutable

Input/Output

Algorithm

Structure and Class

Template

Miscellanous

Let start it!

GTK D

Thanks To

Object

.

......

Interface..

1 interface foo { …}

class..

1 class bar { …}

inheritance..

1 class bar: foo { …}

multi class inheritance not allowed, instead usedinterface.

. .. 8/122.. .. 8/122.

D Programming .

.

.. . . Forward.

.

. ... Back

D Programming

Jonathan MERCIER

IntroductionObject

Functional

Meta-programming

Parallelism

Ressource Management

Contract

System and Safe Code

Reference and pointer

Generics

Inference

Loops

Functions

Debugs

Versions

Requirement

Editors

BasicsMy first D program

Types

Arrays

String and characters

Const and Immutable

Input/Output

Algorithm

Structure and Class

Template

Miscellanous

Let start it!

GTK D

Thanks To

Object

.

......

Interface..

1 interface foo { …}

class..

1 class bar { …}

inheritance..

1 class bar: foo { …}

multi class inheritance not allowed, instead usedinterface.

. .. 8/122.. .. 8/122.

D Programming .

.

.. . . Forward.

.

. ... Back

D Programming

Jonathan MERCIER

IntroductionObject

Functional

Meta-programming

Parallelism

Ressource Management

Contract

System and Safe Code

Reference and pointer

Generics

Inference

Loops

Functions

Debugs

Versions

Requirement

Editors

BasicsMy first D program

Types

Arrays

String and characters

Const and Immutable

Input/Output

Algorithm

Structure and Class

Template

Miscellanous

Let start it!

GTK D

Thanks To

Object

.

......

Interface..

1 interface foo { …}

class..

1 class bar { …}

inheritance..

1 class bar: foo { …}

multi class inheritance not allowed, instead usedinterface.

. .. 8/122.. .. 8/122.

D Programming .

.

.. . . Forward.

.

. ... Back

D Programming

Jonathan MERCIER

IntroductionObject

Functional

Meta-programming

Parallelism

Ressource Management

Contract

System and Safe Code

Reference and pointer

Generics

Inference

Loops

Functions

Debugs

Versions

Requirement

Editors

BasicsMy first D program

Types

Arrays

String and characters

Const and Immutable

Input/Output

Algorithm

Structure and Class

Template

Miscellanous

Let start it!

GTK D

Thanks To

Object

.

......

Interface..

1 interface foo { …}

class..

1 class bar { …}

inheritance..

1 class bar: foo { …}

multi class inheritance not allowed, instead usedinterface.

. .. 8/122.. .. 8/122.

D Programming .

.

.. . . Forward.

.

. ... Back

D Programming

Jonathan MERCIER

IntroductionObject

Functional

Meta-programming

Parallelism

Ressource Management

Contract

System and Safe Code

Reference and pointer

Generics

Inference

Loops

Functions

Debugs

Versions

Requirement

Editors

BasicsMy first D program

Types

Arrays

String and characters

Const and Immutable

Input/Output

Algorithm

Structure and Class

Template

Miscellanous

Let start it!

GTK D

Thanks To

Plan.....1 Introduction

ObjectFunctionalMeta-programmingParallelismRessource ManagementContractSystem and Safe CodeReference and pointerGenericsInferenceLoopsFunctionsDebugsVersionsRequirementEditors

...2 BasicsMy first D programTypesArraysString and charactersConst and ImmutableInput/OutputAlgorithmStructure and ClassTemplateMiscellanousLet start it!

...3 GTK D

...4 Thanks To. .. 9/122.. .. 9/122.

D Programming .

.

.. . . Forward.

.

. ... Back

D Programming

Jonathan MERCIER

IntroductionObject

Functional

Meta-programming

Parallelism

Ressource Management

Contract

System and Safe Code

Reference and pointer

Generics

Inference

Loops

Functions

Debugs

Versions

Requirement

Editors

BasicsMy first D program

Types

Arrays

String and characters

Const and Immutable

Input/Output

Algorithm

Structure and Class

Template

Miscellanous

Let start it!

GTK D

Thanks To

Functional

.

......

Data immutability

..1 immutable int[] a = [ 4, 6, 1, 2];

Pure functions..

1 pure int square(int x) { return x * x; }

Lambda functions..

1 a.sort!( (x,y) => x < y ); // [ 1, 2, 4, 6 ]

. .. 10/122.. .. 10/122.

D Programming .

.

.. . . Forward.

.

. ... Back

D Programming

Jonathan MERCIER

IntroductionObject

Functional

Meta-programming

Parallelism

Ressource Management

Contract

System and Safe Code

Reference and pointer

Generics

Inference

Loops

Functions

Debugs

Versions

Requirement

Editors

BasicsMy first D program

Types

Arrays

String and characters

Const and Immutable

Input/Output

Algorithm

Structure and Class

Template

Miscellanous

Let start it!

GTK D

Thanks To

Functional

.

......

Data immutability

..1 immutable int[] a = [ 4, 6, 1, 2];

Pure functions..

1 pure int square(int x) { return x * x; }

Lambda functions..

1 a.sort!( (x,y) => x < y ); // [ 1, 2, 4, 6 ]

. .. 10/122.. .. 10/122.

D Programming .

.

.. . . Forward.

.

. ... Back

D Programming

Jonathan MERCIER

IntroductionObject

Functional

Meta-programming

Parallelism

Ressource Management

Contract

System and Safe Code

Reference and pointer

Generics

Inference

Loops

Functions

Debugs

Versions

Requirement

Editors

BasicsMy first D program

Types

Arrays

String and characters

Const and Immutable

Input/Output

Algorithm

Structure and Class

Template

Miscellanous

Let start it!

GTK D

Thanks To

Functional

.

......

Data immutability

..1 immutable int[] a = [ 4, 6, 1, 2];

Pure functions..

1 pure int square(int x) { return x * x; }

Lambda functions..

1 a.sort!( (x,y) => x < y ); // [ 1, 2, 4, 6 ]

. .. 10/122.. .. 10/122.

D Programming .

.

.. . . Forward.

.

. ... Back

D Programming

Jonathan MERCIER

IntroductionObject

Functional

Meta-programming

Parallelism

Ressource Management

Contract

System and Safe Code

Reference and pointer

Generics

Inference

Loops

Functions

Debugs

Versions

Requirement

Editors

BasicsMy first D program

Types

Arrays

String and characters

Const and Immutable

Input/Output

Algorithm

Structure and Class

Template

Miscellanous

Let start it!

GTK D

Thanks To

Plan.....1 Introduction

ObjectFunctionalMeta-programmingParallelismRessource ManagementContractSystem and Safe CodeReference and pointerGenericsInferenceLoopsFunctionsDebugsVersionsRequirementEditors

...2 BasicsMy first D programTypesArraysString and charactersConst and ImmutableInput/OutputAlgorithmStructure and ClassTemplateMiscellanousLet start it!

...3 GTK D

...4 Thanks To. .. 11/122.. . .. 11/122.

D Programming .

.

.. . . Forward.

.

. ... Back

D Programming

Jonathan MERCIER

IntroductionObject

Functional

Meta-programming

Parallelism

Ressource Management

Contract

System and Safe Code

Reference and pointer

Generics

Inference

Loops

Functions

Debugs

Versions

Requirement

Editors

BasicsMy first D program

Types

Arrays

String and characters

Const and Immutable

Input/Output

Algorithm

Structure and Class

Template

Miscellanous

Let start it!

GTK D

Thanks To

Meta-programming

.Combination of..

......

templates

compile time function executiontuplesstring mixins

. .. 12/122.. . .. 12/122.

D Programming .

.

.. . . Forward.

.

. ... Back

D Programming

Jonathan MERCIER

IntroductionObject

Functional

Meta-programming

Parallelism

Ressource Management

Contract

System and Safe Code

Reference and pointer

Generics

Inference

Loops

Functions

Debugs

Versions

Requirement

Editors

BasicsMy first D program

Types

Arrays

String and characters

Const and Immutable

Input/Output

Algorithm

Structure and Class

Template

Miscellanous

Let start it!

GTK D

Thanks To

Meta-programming

.Combination of..

......

templatescompile time function execution

tuplesstring mixins

. .. 12/122.. . .. 12/122.

D Programming .

.

.. . . Forward.

.

. ... Back

D Programming

Jonathan MERCIER

IntroductionObject

Functional

Meta-programming

Parallelism

Ressource Management

Contract

System and Safe Code

Reference and pointer

Generics

Inference

Loops

Functions

Debugs

Versions

Requirement

Editors

BasicsMy first D program

Types

Arrays

String and characters

Const and Immutable

Input/Output

Algorithm

Structure and Class

Template

Miscellanous

Let start it!

GTK D

Thanks To

Meta-programming

.Combination of..

......

templatescompile time function executiontuples

string mixins

. .. 12/122.. . .. 12/122.

D Programming .

.

.. . . Forward.

.

. ... Back

D Programming

Jonathan MERCIER

IntroductionObject

Functional

Meta-programming

Parallelism

Ressource Management

Contract

System and Safe Code

Reference and pointer

Generics

Inference

Loops

Functions

Debugs

Versions

Requirement

Editors

BasicsMy first D program

Types

Arrays

String and characters

Const and Immutable

Input/Output

Algorithm

Structure and Class

Template

Miscellanous

Let start it!

GTK D

Thanks To

Meta-programming

.Combination of..

......

templatescompile time function executiontuplesstring mixins

. .. 12/122.. . .. 12/122.

D Programming .

.

.. . . Forward.

.

. ... Back

D Programming

Jonathan MERCIER

IntroductionObject

Functional

Meta-programming

Parallelism

Ressource Management

Contract

System and Safe Code

Reference and pointer

Generics

Inference

Loops

Functions

Debugs

Versions

Requirement

Editors

BasicsMy first D program

Types

Arrays

String and characters

Const and Immutable

Input/Output

Algorithm

Structure and Class

Template

Miscellanous

Let start it!

GTK D

Thanks To

Meta-programming

..

Code 1: Example1 template Factorial(ulong n){2 static if(n < 2)3 const Factorial = 1;4 else5 const Factorial = n * Factorial!(n − 1);6 }7 const ulong var = Factorial!( 8 ); // compute at compile−time

. .. 13/122.. . .. 13/122.

D Programming .

.

.. . . Forward.

.

. ... Back

D Programming

Jonathan MERCIER

IntroductionObject

Functional

Meta-programming

Parallelism

Ressource Management

Contract

System and Safe Code

Reference and pointer

Generics

Inference

Loops

Functions

Debugs

Versions

Requirement

Editors

BasicsMy first D program

Types

Arrays

String and characters

Const and Immutable

Input/Output

Algorithm

Structure and Class

Template

Miscellanous

Let start it!

GTK D

Thanks To

Plan.....1 Introduction

ObjectFunctionalMeta-programmingParallelismRessource ManagementContractSystem and Safe CodeReference and pointerGenericsInferenceLoopsFunctionsDebugsVersionsRequirementEditors

...2 BasicsMy first D programTypesArraysString and charactersConst and ImmutableInput/OutputAlgorithmStructure and ClassTemplateMiscellanousLet start it!

...3 GTK D

...4 Thanks To. .. 14/122.. . .. 14/122.

D Programming .

.

.. . . Forward.

.

. ... Back

D Programming

Jonathan MERCIER

IntroductionObject

Functional

Meta-programming

Parallelism

Ressource Management

Contract

System and Safe Code

Reference and pointer

Generics

Inference

Loops

Functions

Debugs

Versions

Requirement

Editors

BasicsMy first D program

Types

Arrays

String and characters

Const and Immutable

Input/Output

Algorithm

Structure and Class

Template

Miscellanous

Let start it!

GTK D

Thanks To

Parallelism

.

......

module to use..

1 import std.parallelism;

parallel loop

..1 foreach( i; parallel( list ) ){ …}

Pool thread

..

1 void myfunction( int param1, int param 2 ){ …}2 auto myTask = task!myfunction( param1, param2 );3 taskPool.put( myTask );4 doSomething(); // another work in parallel5 taskPool.finish( true ); // wait alls jobs ending

. .. 15/122.. . .. 15/122.

D Programming .

.

.. . . Forward.

.

. ... Back

D Programming

Jonathan MERCIER

IntroductionObject

Functional

Meta-programming

Parallelism

Ressource Management

Contract

System and Safe Code

Reference and pointer

Generics

Inference

Loops

Functions

Debugs

Versions

Requirement

Editors

BasicsMy first D program

Types

Arrays

String and characters

Const and Immutable

Input/Output

Algorithm

Structure and Class

Template

Miscellanous

Let start it!

GTK D

Thanks To

Parallelism

.

......

module to use..

1 import std.parallelism;

parallel loop

..1 foreach( i; parallel( list ) ){ …}

Pool thread

..

1 void myfunction( int param1, int param 2 ){ …}2 auto myTask = task!myfunction( param1, param2 );3 taskPool.put( myTask );4 doSomething(); // another work in parallel5 taskPool.finish( true ); // wait alls jobs ending

. .. 15/122.. . .. 15/122.

D Programming .

.

.. . . Forward.

.

. ... Back

D Programming

Jonathan MERCIER

IntroductionObject

Functional

Meta-programming

Parallelism

Ressource Management

Contract

System and Safe Code

Reference and pointer

Generics

Inference

Loops

Functions

Debugs

Versions

Requirement

Editors

BasicsMy first D program

Types

Arrays

String and characters

Const and Immutable

Input/Output

Algorithm

Structure and Class

Template

Miscellanous

Let start it!

GTK D

Thanks To

Parallelism

.

......

module to use..

1 import std.parallelism;

parallel loop

..1 foreach( i; parallel( list ) ){ …}

Pool thread

..

1 void myfunction( int param1, int param 2 ){ …}2 auto myTask = task!myfunction( param1, param2 );3 taskPool.put( myTask );4 doSomething(); // another work in parallel5 taskPool.finish( true ); // wait alls jobs ending

. .. 15/122.. . .. 15/122.

D Programming .

.

.. . . Forward.

.

. ... Back

D Programming

Jonathan MERCIER

IntroductionObject

Functional

Meta-programming

Parallelism

Ressource Management

Contract

System and Safe Code

Reference and pointer

Generics

Inference

Loops

Functions

Debugs

Versions

Requirement

Editors

BasicsMy first D program

Types

Arrays

String and characters

Const and Immutable

Input/Output

Algorithm

Structure and Class

Template

Miscellanous

Let start it!

GTK D

Thanks To

Plan.....1 Introduction

ObjectFunctionalMeta-programmingParallelismRessource ManagementContractSystem and Safe CodeReference and pointerGenericsInferenceLoopsFunctionsDebugsVersionsRequirementEditors

...2 BasicsMy first D programTypesArraysString and charactersConst and ImmutableInput/OutputAlgorithmStructure and ClassTemplateMiscellanousLet start it!

...3 GTK D

...4 Thanks To. .. 16/122.. . . .. 16/122.

D Programming .

.

.. . . Forward.

.

. ... Back

D Programming

Jonathan MERCIER

IntroductionObject

Functional

Meta-programming

Parallelism

Ressource Management

Contract

System and Safe Code

Reference and pointer

Generics

Inference

Loops

Functions

Debugs

Versions

Requirement

Editors

BasicsMy first D program

Types

Arrays

String and characters

Const and Immutable

Input/Output

Algorithm

Structure and Class

Template

Miscellanous

Let start it!

GTK D

Thanks To

Ressource Management

..

Code 2: Example1 File f = File( ”myfile.txt”, ”r”);2 scope(exit) f.close();3 lockFile( f );4 doFoo( f );5 scope(success) doBar( f );6 scope(failure) unlock( f );

. .. 17/122.. . . .. 17/122.

D Programming .

.

.. . . Forward.

.

. ... Back

D Programming

Jonathan MERCIER

IntroductionObject

Functional

Meta-programming

Parallelism

Ressource Management

Contract

System and Safe Code

Reference and pointer

Generics

Inference

Loops

Functions

Debugs

Versions

Requirement

Editors

BasicsMy first D program

Types

Arrays

String and characters

Const and Immutable

Input/Output

Algorithm

Structure and Class

Template

Miscellanous

Let start it!

GTK D

Thanks To

Plan.....1 Introduction

ObjectFunctionalMeta-programmingParallelismRessource ManagementContractSystem and Safe CodeReference and pointerGenericsInferenceLoopsFunctionsDebugsVersionsRequirementEditors

...2 BasicsMy first D programTypesArraysString and charactersConst and ImmutableInput/OutputAlgorithmStructure and ClassTemplateMiscellanousLet start it!

...3 GTK D

...4 Thanks To. .. 18/122.. . . .. 18/122.

D Programming .

.

.. . . Forward.

.

. ... Back

D Programming

Jonathan MERCIER

IntroductionObject

Functional

Meta-programming

Parallelism

Ressource Management

Contract

System and Safe Code

Reference and pointer

Generics

Inference

Loops

Functions

Debugs

Versions

Requirement

Editors

BasicsMy first D program

Types

Arrays

String and characters

Const and Immutable

Input/Output

Algorithm

Structure and Class

Template

Miscellanous

Let start it!

GTK D

Thanks To

Contract.

......

check a statement..

1 assert( var != null );

check before entering into a function

..

1 double foo ( int a )2 in{ assert( a > 0 ); }3 body { return a − 2; }

check at function exit

..

1 int foo ( int a )2 out{ assert( a > 0 ); }3 body { return a − 2; }

-release flag will not compute contract

..$ ldc2 -release foo.d

. .. 19/122.. . . .. 19/122.

D Programming .

.

.. . . Forward.

.

. ... Back

D Programming

Jonathan MERCIER

IntroductionObject

Functional

Meta-programming

Parallelism

Ressource Management

Contract

System and Safe Code

Reference and pointer

Generics

Inference

Loops

Functions

Debugs

Versions

Requirement

Editors

BasicsMy first D program

Types

Arrays

String and characters

Const and Immutable

Input/Output

Algorithm

Structure and Class

Template

Miscellanous

Let start it!

GTK D

Thanks To

Contract.

......

check a statement..

1 assert( var != null );

check before entering into a function

..

1 double foo ( int a )2 in{ assert( a > 0 ); }3 body { return a − 2; }

check at function exit

..

1 int foo ( int a )2 out{ assert( a > 0 ); }3 body { return a − 2; }

-release flag will not compute contract

..$ ldc2 -release foo.d

. .. 19/122.. . . .. 19/122.

D Programming .

.

.. . . Forward.

.

. ... Back

D Programming

Jonathan MERCIER

IntroductionObject

Functional

Meta-programming

Parallelism

Ressource Management

Contract

System and Safe Code

Reference and pointer

Generics

Inference

Loops

Functions

Debugs

Versions

Requirement

Editors

BasicsMy first D program

Types

Arrays

String and characters

Const and Immutable

Input/Output

Algorithm

Structure and Class

Template

Miscellanous

Let start it!

GTK D

Thanks To

Contract.

......

check a statement..

1 assert( var != null );

check before entering into a function

..

1 double foo ( int a )2 in{ assert( a > 0 ); }3 body { return a − 2; }

check at function exit

..

1 int foo ( int a )2 out{ assert( a > 0 ); }3 body { return a − 2; }

-release flag will not compute contract

..$ ldc2 -release foo.d

. .. 19/122.. . . .. 19/122.

D Programming .

.

.. . . Forward.

.

. ... Back

D Programming

Jonathan MERCIER

IntroductionObject

Functional

Meta-programming

Parallelism

Ressource Management

Contract

System and Safe Code

Reference and pointer

Generics

Inference

Loops

Functions

Debugs

Versions

Requirement

Editors

BasicsMy first D program

Types

Arrays

String and characters

Const and Immutable

Input/Output

Algorithm

Structure and Class

Template

Miscellanous

Let start it!

GTK D

Thanks To

Contract.

......

check a statement..

1 assert( var != null );

check before entering into a function

..

1 double foo ( int a )2 in{ assert( a > 0 ); }3 body { return a − 2; }

check at function exit

..

1 int foo ( int a )2 out{ assert( a > 0 ); }3 body { return a − 2; }

-release flag will not compute contract

..$ ldc2 -release foo.d

. .. 19/122.. . . .. 19/122.

D Programming .

.

.. . . Forward.

.

. ... Back

D Programming

Jonathan MERCIER

IntroductionObject

Functional

Meta-programming

Parallelism

Ressource Management

Contract

System and Safe Code

Reference and pointer

Generics

Inference

Loops

Functions

Debugs

Versions

Requirement

Editors

BasicsMy first D program

Types

Arrays

String and characters

Const and Immutable

Input/Output

Algorithm

Structure and Class

Template

Miscellanous

Let start it!

GTK D

Thanks To

Plan.....1 Introduction

ObjectFunctionalMeta-programmingParallelismRessource ManagementContractSystem and Safe CodeReference and pointerGenericsInferenceLoopsFunctionsDebugsVersionsRequirementEditors

...2 BasicsMy first D programTypesArraysString and charactersConst and ImmutableInput/OutputAlgorithmStructure and ClassTemplateMiscellanousLet start it!

...3 GTK D

...4 Thanks To. .. 20/122.. . . .. 20/122.

D Programming .

.

.. . . Forward.

.

. ... Back

D Programming

Jonathan MERCIER

IntroductionObject

Functional

Meta-programming

Parallelism

Ressource Management

Contract

System and Safe Code

Reference and pointer

Generics

Inference

Loops

Functions

Debugs

Versions

Requirement

Editors

BasicsMy first D program

Types

Arrays

String and characters

Const and Immutable

Input/Output

Algorithm

Structure and Class

Template

Miscellanous

Let start it!

GTK D

Thanks To

System and Safe Code

.System and Safe Code..

......

Safe functions are functions that are statically checkedto have no possibility of undefined behavior.

Undefined behavior is often used as a vector formalicious attacks.

Func­tions are marked with at­tributes: @safe,@system, @trusted

. .. 21/122.. . . . .. 21/122.

D Programming .

.

.. . . Forward.

.

. ... Back

D Programming

Jonathan MERCIER

IntroductionObject

Functional

Meta-programming

Parallelism

Ressource Management

Contract

System and Safe Code

Reference and pointer

Generics

Inference

Loops

Functions

Debugs

Versions

Requirement

Editors

BasicsMy first D program

Types

Arrays

String and characters

Const and Immutable

Input/Output

Algorithm

Structure and Class

Template

Miscellanous

Let start it!

GTK D

Thanks To

Plan.....1 Introduction

ObjectFunctionalMeta-programmingParallelismRessource ManagementContractSystem and Safe CodeReference and pointerGenericsInferenceLoopsFunctionsDebugsVersionsRequirementEditors

...2 BasicsMy first D programTypesArraysString and charactersConst and ImmutableInput/OutputAlgorithmStructure and ClassTemplateMiscellanousLet start it!

...3 GTK D

...4 Thanks To. .. 22/122.. . . . .. 22/122.

D Programming .

.

.. . . Forward.

.

. ... Back

D Programming

Jonathan MERCIER

IntroductionObject

Functional

Meta-programming

Parallelism

Ressource Management

Contract

System and Safe Code

Reference and pointer

Generics

Inference

Loops

Functions

Debugs

Versions

Requirement

Editors

BasicsMy first D program

Types

Arrays

String and characters

Const and Immutable

Input/Output

Algorithm

Structure and Class

Template

Miscellanous

Let start it!

GTK D

Thanks To

Reference and pointer

.

......

Pointers exist only to create C interface code

..1 int* a = cFunction( param );

ref into function..

1 void foo( ref int[] param ) { …}

ref into a loop

..1 foreach( ref item ; list ){ …}

. .. 23/122.. . . . .. 23/122.

D Programming .

.

.. . . Forward.

.

. ... Back

D Programming

Jonathan MERCIER

IntroductionObject

Functional

Meta-programming

Parallelism

Ressource Management

Contract

System and Safe Code

Reference and pointer

Generics

Inference

Loops

Functions

Debugs

Versions

Requirement

Editors

BasicsMy first D program

Types

Arrays

String and characters

Const and Immutable

Input/Output

Algorithm

Structure and Class

Template

Miscellanous

Let start it!

GTK D

Thanks To

Reference and pointer

.

......

Pointers exist only to create C interface code

..1 int* a = cFunction( param );

ref into function..

1 void foo( ref int[] param ) { …}

ref into a loop

..1 foreach( ref item ; list ){ …}

. .. 23/122.. . . . .. 23/122.

D Programming .

.

.. . . Forward.

.

. ... Back

D Programming

Jonathan MERCIER

IntroductionObject

Functional

Meta-programming

Parallelism

Ressource Management

Contract

System and Safe Code

Reference and pointer

Generics

Inference

Loops

Functions

Debugs

Versions

Requirement

Editors

BasicsMy first D program

Types

Arrays

String and characters

Const and Immutable

Input/Output

Algorithm

Structure and Class

Template

Miscellanous

Let start it!

GTK D

Thanks To

Reference and pointer

.

......

Pointers exist only to create C interface code

..1 int* a = cFunction( param );

ref into function..

1 void foo( ref int[] param ) { …}

ref into a loop

..1 foreach( ref item ; list ){ …}

. .. 23/122.. . . . .. 23/122.

D Programming .

.

.. . . Forward.

.

. ... Back

D Programming

Jonathan MERCIER

IntroductionObject

Functional

Meta-programming

Parallelism

Ressource Management

Contract

System and Safe Code

Reference and pointer

Generics

Inference

Loops

Functions

Debugs

Versions

Requirement

Editors

BasicsMy first D program

Types

Arrays

String and characters

Const and Immutable

Input/Output

Algorithm

Structure and Class

Template

Miscellanous

Let start it!

GTK D

Thanks To

Plan.....1 Introduction

ObjectFunctionalMeta-programmingParallelismRessource ManagementContractSystem and Safe CodeReference and pointerGenericsInferenceLoopsFunctionsDebugsVersionsRequirementEditors

...2 BasicsMy first D programTypesArraysString and charactersConst and ImmutableInput/OutputAlgorithmStructure and ClassTemplateMiscellanousLet start it!

...3 GTK D

...4 Thanks To. .. 24/122.. . . . .. 24/122.

D Programming .

.

.. . . Forward.

.

. ... Back

D Programming

Jonathan MERCIER

IntroductionObject

Functional

Meta-programming

Parallelism

Ressource Management

Contract

System and Safe Code

Reference and pointer

Generics

Inference

Loops

Functions

Debugs

Versions

Requirement

Editors

BasicsMy first D program

Types

Arrays

String and characters

Const and Immutable

Input/Output

Algorithm

Structure and Class

Template

Miscellanous

Let start it!

GTK D

Thanks To

.Generic..

......

class

..1 class Foo( T ){ …}2 Foo!int instance = new Foo!(int)( param );

structure

..1 struct Foo( T ){ …}2 Foo!int instance = Foo!int( param );

function

..1 T foo( T )(T param){ …}2 int var = foo!int( param );

macro

..

1 template TFoo( T )( T param ){ immutable T f = param + 3;}

2 int a = TFoo!int( 4 ) ; // return 7 at compile time

. .. 25/122.. . . . .. 25/122.

D Programming .

.

.. . . Forward.

.

. ... Back

D Programming

Jonathan MERCIER

IntroductionObject

Functional

Meta-programming

Parallelism

Ressource Management

Contract

System and Safe Code

Reference and pointer

Generics

Inference

Loops

Functions

Debugs

Versions

Requirement

Editors

BasicsMy first D program

Types

Arrays

String and characters

Const and Immutable

Input/Output

Algorithm

Structure and Class

Template

Miscellanous

Let start it!

GTK D

Thanks To

.Generic..

......

class

..1 class Foo( T ){ …}2 Foo!int instance = new Foo!(int)( param );

structure

..1 struct Foo( T ){ …}2 Foo!int instance = Foo!int( param );

function

..1 T foo( T )(T param){ …}2 int var = foo!int( param );

macro

..

1 template TFoo( T )( T param ){ immutable T f = param + 3;}

2 int a = TFoo!int( 4 ) ; // return 7 at compile time

. .. 25/122.. . . . .. 25/122.

D Programming .

.

.. . . Forward.

.

. ... Back

D Programming

Jonathan MERCIER

IntroductionObject

Functional

Meta-programming

Parallelism

Ressource Management

Contract

System and Safe Code

Reference and pointer

Generics

Inference

Loops

Functions

Debugs

Versions

Requirement

Editors

BasicsMy first D program

Types

Arrays

String and characters

Const and Immutable

Input/Output

Algorithm

Structure and Class

Template

Miscellanous

Let start it!

GTK D

Thanks To

.Generic..

......

class

..1 class Foo( T ){ …}2 Foo!int instance = new Foo!(int)( param );

structure

..1 struct Foo( T ){ …}2 Foo!int instance = Foo!int( param );

function

..1 T foo( T )(T param){ …}2 int var = foo!int( param );

macro

..

1 template TFoo( T )( T param ){ immutable T f = param + 3;}

2 int a = TFoo!int( 4 ) ; // return 7 at compile time

. .. 25/122.. . . . .. 25/122.

D Programming .

.

.. . . Forward.

.

. ... Back

D Programming

Jonathan MERCIER

IntroductionObject

Functional

Meta-programming

Parallelism

Ressource Management

Contract

System and Safe Code

Reference and pointer

Generics

Inference

Loops

Functions

Debugs

Versions

Requirement

Editors

BasicsMy first D program

Types

Arrays

String and characters

Const and Immutable

Input/Output

Algorithm

Structure and Class

Template

Miscellanous

Let start it!

GTK D

Thanks To

.Generic..

......

class

..1 class Foo( T ){ …}2 Foo!int instance = new Foo!(int)( param );

structure

..1 struct Foo( T ){ …}2 Foo!int instance = Foo!int( param );

function

..1 T foo( T )(T param){ …}2 int var = foo!int( param );

macro

..

1 template TFoo( T )( T param ){ immutable T f = param + 3;}

2 int a = TFoo!int( 4 ) ; // return 7 at compile time

. .. 25/122.. . . . .. 25/122.

D Programming .

.

.. . . Forward.

.

. ... Back

D Programming

Jonathan MERCIER

IntroductionObject

Functional

Meta-programming

Parallelism

Ressource Management

Contract

System and Safe Code

Reference and pointer

Generics

Inference

Loops

Functions

Debugs

Versions

Requirement

Editors

BasicsMy first D program

Types

Arrays

String and characters

Const and Immutable

Input/Output

Algorithm

Structure and Class

Template

Miscellanous

Let start it!

GTK D

Thanks To

Plan.....1 Introduction

ObjectFunctionalMeta-programmingParallelismRessource ManagementContractSystem and Safe CodeReference and pointerGenericsInferenceLoopsFunctionsDebugsVersionsRequirementEditors

...2 BasicsMy first D programTypesArraysString and charactersConst and ImmutableInput/OutputAlgorithmStructure and ClassTemplateMiscellanousLet start it!

...3 GTK D

...4 Thanks To. .. 26/122.. . . . . .. 26/122.

D Programming .

.

.. . . Forward.

.

. ... Back

D Programming

Jonathan MERCIER

IntroductionObject

Functional

Meta-programming

Parallelism

Ressource Management

Contract

System and Safe Code

Reference and pointer

Generics

Inference

Loops

Functions

Debugs

Versions

Requirement

Editors

BasicsMy first D program

Types

Arrays

String and characters

Const and Immutable

Input/Output

Algorithm

Structure and Class

Template

Miscellanous

Let start it!

GTK D

Thanks To

Inference

.

......

auto for variable

..1 size_t[] list = [ 0, 1, 2, 3, 4];2 auto item = list[1]; // item type is size_t

auto for function..

1 auto foo( int param ){ …}

. .. 27/122.. . . . . .. 27/122.

D Programming .

.

.. . . Forward.

.

. ... Back

D Programming

Jonathan MERCIER

IntroductionObject

Functional

Meta-programming

Parallelism

Ressource Management

Contract

System and Safe Code

Reference and pointer

Generics

Inference

Loops

Functions

Debugs

Versions

Requirement

Editors

BasicsMy first D program

Types

Arrays

String and characters

Const and Immutable

Input/Output

Algorithm

Structure and Class

Template

Miscellanous

Let start it!

GTK D

Thanks To

Inference

.

......

auto for variable

..1 size_t[] list = [ 0, 1, 2, 3, 4];2 auto item = list[1]; // item type is size_t

auto for function..

1 auto foo( int param ){ …}

. .. 27/122.. . . . . .. 27/122.

D Programming .

.

.. . . Forward.

.

. ... Back

D Programming

Jonathan MERCIER

IntroductionObject

Functional

Meta-programming

Parallelism

Ressource Management

Contract

System and Safe Code

Reference and pointer

Generics

Inference

Loops

Functions

Debugs

Versions

Requirement

Editors

BasicsMy first D program

Types

Arrays

String and characters

Const and Immutable

Input/Output

Algorithm

Structure and Class

Template

Miscellanous

Let start it!

GTK D

Thanks To

Plan.....1 Introduction

ObjectFunctionalMeta-programmingParallelismRessource ManagementContractSystem and Safe CodeReference and pointerGenericsInferenceLoopsFunctionsDebugsVersionsRequirementEditors

...2 BasicsMy first D programTypesArraysString and charactersConst and ImmutableInput/OutputAlgorithmStructure and ClassTemplateMiscellanousLet start it!

...3 GTK D

...4 Thanks To. .. 28/122.. . . . . .. 28/122.

D Programming .

.

.. . . Forward.

.

. ... Back

D Programming

Jonathan MERCIER

IntroductionObject

Functional

Meta-programming

Parallelism

Ressource Management

Contract

System and Safe Code

Reference and pointer

Generics

Inference

Loops

Functions

Debugs

Versions

Requirement

Editors

BasicsMy first D program

Types

Arrays

String and characters

Const and Immutable

Input/Output

Algorithm

Structure and Class

Template

Miscellanous

Let start it!

GTK D

Thanks To

Loops.Loops..

......

for loop

..1 for( int i = 0; i < 10; i++ ){ …}

while loop

..1 while( isComputing ){ …}

do while..

1 do{ …}while( isComputing );

foreach loop

..

1 foreach( size_t i; list ){ …}2 foreach( size_t counter, size_t i = 0; list ){ …}3 foreach( counter, i; list ){ …}

. .. 29/122.. . . . . .. 29/122.

D Programming .

.

.. . . Forward.

.

. ... Back

D Programming

Jonathan MERCIER

IntroductionObject

Functional

Meta-programming

Parallelism

Ressource Management

Contract

System and Safe Code

Reference and pointer

Generics

Inference

Loops

Functions

Debugs

Versions

Requirement

Editors

BasicsMy first D program

Types

Arrays

String and characters

Const and Immutable

Input/Output

Algorithm

Structure and Class

Template

Miscellanous

Let start it!

GTK D

Thanks To

Plan.....1 Introduction

ObjectFunctionalMeta-programmingParallelismRessource ManagementContractSystem and Safe CodeReference and pointerGenericsInferenceLoopsFunctionsDebugsVersionsRequirementEditors

...2 BasicsMy first D programTypesArraysString and charactersConst and ImmutableInput/OutputAlgorithmStructure and ClassTemplateMiscellanousLet start it!

...3 GTK D

...4 Thanks To. .. 30/122.. . . . . .. 30/122.

D Programming .

.

.. . . Forward.

.

. ... Back

D Programming

Jonathan MERCIER

IntroductionObject

Functional

Meta-programming

Parallelism

Ressource Management

Contract

System and Safe Code

Reference and pointer

Generics

Inference

Loops

Functions

Debugs

Versions

Requirement

Editors

BasicsMy first D program

Types

Arrays

String and characters

Const and Immutable

Input/Output

Algorithm

Structure and Class

Template

Miscellanous

Let start it!

GTK D

Thanks To

Functions

.Functions..

......

classical..

1 void foo( int param ){ …}

with default values..

1 void foo( int param1, int param2 = 3 ){ …}

with variadic parameters

..

1 void foo( int[] params ... ) {2 foreach( param; params )3 …// do something4 }

. .. 31/122.. . . . . . .. 31/122.

D Programming .

.

.. . . Forward.

.

. ... Back

D Programming

Jonathan MERCIER

IntroductionObject

Functional

Meta-programming

Parallelism

Ressource Management

Contract

System and Safe Code

Reference and pointer

Generics

Inference

Loops

Functions

Debugs

Versions

Requirement

Editors

BasicsMy first D program

Types

Arrays

String and characters

Const and Immutable

Input/Output

Algorithm

Structure and Class

Template

Miscellanous

Let start it!

GTK D

Thanks To

Functions

.Functions..

......

classical..

1 void foo( int param ){ …}

with default values..

1 void foo( int param1, int param2 = 3 ){ …}

with variadic parameters

..

1 void foo( int[] params ... ) {2 foreach( param; params )3 …// do something4 }

. .. 31/122.. . . . . . .. 31/122.

D Programming .

.

.. . . Forward.

.

. ... Back

D Programming

Jonathan MERCIER

IntroductionObject

Functional

Meta-programming

Parallelism

Ressource Management

Contract

System and Safe Code

Reference and pointer

Generics

Inference

Loops

Functions

Debugs

Versions

Requirement

Editors

BasicsMy first D program

Types

Arrays

String and characters

Const and Immutable

Input/Output

Algorithm

Structure and Class

Template

Miscellanous

Let start it!

GTK D

Thanks To

Functions

.Functions..

......

classical..

1 void foo( int param ){ …}

with default values..

1 void foo( int param1, int param2 = 3 ){ …}

with variadic parameters

..

1 void foo( int[] params ... ) {2 foreach( param; params )3 …// do something4 }

. .. 31/122.. . . . . . .. 31/122.

D Programming .

.

.. . . Forward.

.

. ... Back

D Programming

Jonathan MERCIER

IntroductionObject

Functional

Meta-programming

Parallelism

Ressource Management

Contract

System and Safe Code

Reference and pointer

Generics

Inference

Loops

Functions

Debugs

Versions

Requirement

Editors

BasicsMy first D program

Types

Arrays

String and characters

Const and Immutable

Input/Output

Algorithm

Structure and Class

Template

Miscellanous

Let start it!

GTK D

Thanks To

Plan.....1 Introduction

ObjectFunctionalMeta-programmingParallelismRessource ManagementContractSystem and Safe CodeReference and pointerGenericsInferenceLoopsFunctionsDebugsVersionsRequirementEditors

...2 BasicsMy first D programTypesArraysString and charactersConst and ImmutableInput/OutputAlgorithmStructure and ClassTemplateMiscellanousLet start it!

...3 GTK D

...4 Thanks To. .. 32/122.. . . . . . .. 32/122.

D Programming .

.

.. . . Forward.

.

. ... Back

D Programming

Jonathan MERCIER

IntroductionObject

Functional

Meta-programming

Parallelism

Ressource Management

Contract

System and Safe Code

Reference and pointer

Generics

Inference

Loops

Functions

Debugs

Versions

Requirement

Editors

BasicsMy first D program

Types

Arrays

String and characters

Const and Immutable

Input/Output

Algorithm

Structure and Class

Template

Miscellanous

Let start it!

GTK D

Thanks To

Debugs

.Debugs..

......

debug block

..1 debug( int param ){ …} // ldc2 −d−debug …..

debug line

..1 debug writeln( ”foo” ) ;

unitest

..

1 unitest {2 assert( doFoo( x ), true );3 assert( doBar( x ), 3 );4 …5 }

.

. .. 33/122.. . . . . . .. 33/122.

D Programming .

.

.. . . Forward.

.

. ... Back

D Programming

Jonathan MERCIER

IntroductionObject

Functional

Meta-programming

Parallelism

Ressource Management

Contract

System and Safe Code

Reference and pointer

Generics

Inference

Loops

Functions

Debugs

Versions

Requirement

Editors

BasicsMy first D program

Types

Arrays

String and characters

Const and Immutable

Input/Output

Algorithm

Structure and Class

Template

Miscellanous

Let start it!

GTK D

Thanks To

Debugs

.Debugs..

......

debug block

..1 debug( int param ){ …}

debug line

..1 debug writeln( ”foo” ) ; // ldc2 −d−debug …..

unitest

..

1 unitest {2 assert( doFoo( x ), true );3 assert( doBar( x ), 3 );4 …5 }

.

. .. 34/122.. . . . . . .. 34/122.

D Programming .

.

.. . . Forward.

.

. ... Back

D Programming

Jonathan MERCIER

IntroductionObject

Functional

Meta-programming

Parallelism

Ressource Management

Contract

System and Safe Code

Reference and pointer

Generics

Inference

Loops

Functions

Debugs

Versions

Requirement

Editors

BasicsMy first D program

Types

Arrays

String and characters

Const and Immutable

Input/Output

Algorithm

Structure and Class

Template

Miscellanous

Let start it!

GTK D

Thanks To

Debugs

.Debugs..

......

debug block

..1 debug( int param ){ …}

debug line

..1 debug writeln( ”foo” ) ;

unitest

..

1 unitest { // ldc2 −unittest …..2 assert( doFoo( x ), true );3 assert( doBar( x ), 3 );4 …5 }

.

. .. 35/122.. . . . . . .. 35/122.

D Programming .

.

.. . . Forward.

.

. ... Back

D Programming

Jonathan MERCIER

IntroductionObject

Functional

Meta-programming

Parallelism

Ressource Management

Contract

System and Safe Code

Reference and pointer

Generics

Inference

Loops

Functions

Debugs

Versions

Requirement

Editors

BasicsMy first D program

Types

Arrays

String and characters

Const and Immutable

Input/Output

Algorithm

Structure and Class

Template

Miscellanous

Let start it!

GTK D

Thanks To

Plan.....1 Introduction

ObjectFunctionalMeta-programmingParallelismRessource ManagementContractSystem and Safe CodeReference and pointerGenericsInferenceLoopsFunctionsDebugsVersionsRequirementEditors

...2 BasicsMy first D programTypesArraysString and charactersConst and ImmutableInput/OutputAlgorithmStructure and ClassTemplateMiscellanousLet start it!

...3 GTK D

...4 Thanks To. .. 36/122.. . . . . . . .. 36/122.

D Programming .

.

.. . . Forward.

.

. ... Back

D Programming

Jonathan MERCIER

IntroductionObject

Functional

Meta-programming

Parallelism

Ressource Management

Contract

System and Safe Code

Reference and pointer

Generics

Inference

Loops

Functions

Debugs

Versions

Requirement

Editors

BasicsMy first D program

Types

Arrays

String and characters

Const and Immutable

Input/Output

Algorithm

Structure and Class

Template

Miscellanous

Let start it!

GTK D

Thanks To

Versions

.Versions..

......

version conditional code block to use

..

1 version( Windows ){ …}2 else version( linux ){ …}3 else { pragma( msg, ”Unknown operating syystem” ); }

. .. 37/122.. . . . . . . .. 37/122.

D Programming .

.

.. . . Forward.

.

. ... Back

D Programming

Jonathan MERCIER

IntroductionObject

Functional

Meta-programming

Parallelism

Ressource Management

Contract

System and Safe Code

Reference and pointer

Generics

Inference

Loops

Functions

Debugs

Versions

Requirement

Editors

BasicsMy first D program

Types

Arrays

String and characters

Const and Immutable

Input/Output

Algorithm

Structure and Class

Template

Miscellanous

Let start it!

GTK D

Thanks To

Versions

.Versions..

......

own version identifier

..

1 version( FullApp ){ …}2 else version( DemoApp ){ …}3 else { version = DemoApp ); }

from command line give wich version to compile

..

Code 3: Terminal$ ldc2 -d-version="FullApp" myApp.d

. .. 38/122.. . . . . . . .. 38/122.

D Programming .

.

.. . . Forward.

.

. ... Back

D Programming

Jonathan MERCIER

IntroductionObject

Functional

Meta-programming

Parallelism

Ressource Management

Contract

System and Safe Code

Reference and pointer

Generics

Inference

Loops

Functions

Debugs

Versions

Requirement

Editors

BasicsMy first D program

Types

Arrays

String and characters

Const and Immutable

Input/Output

Algorithm

Structure and Class

Template

Miscellanous

Let start it!

GTK D

Thanks To

Versions

.Versions..

......

own version identifier

..

1 version( FullApp ){ …}2 else version( DemoApp ){ …}3 else { version = DemoApp ); }

from command line give wich version to compile

..

Code 4: Terminal$ ldc2 -d-version="FullApp" myApp.d

. .. 38/122.. . . . . . . .. 38/122.

D Programming .

.

.. . . Forward.

.

. ... Back

D Programming

Jonathan MERCIER

IntroductionObject

Functional

Meta-programming

Parallelism

Ressource Management

Contract

System and Safe Code

Reference and pointer

Generics

Inference

Loops

Functions

Debugs

Versions

Requirement

Editors

BasicsMy first D program

Types

Arrays

String and characters

Const and Immutable

Input/Output

Algorithm

Structure and Class

Template

Miscellanous

Let start it!

GTK D

Thanks To

Plan.....1 Introduction

ObjectFunctionalMeta-programmingParallelismRessource ManagementContractSystem and Safe CodeReference and pointerGenericsInferenceLoopsFunctionsDebugsVersionsRequirementEditors

...2 BasicsMy first D programTypesArraysString and charactersConst and ImmutableInput/OutputAlgorithmStructure and ClassTemplateMiscellanousLet start it!

...3 GTK D

...4 Thanks To. .. 39/122.. . . . . . . .. 39/122.

D Programming .

.

.. . . Forward.

.

. ... Back

D Programming

Jonathan MERCIER

IntroductionObject

Functional

Meta-programming

Parallelism

Ressource Management

Contract

System and Safe Code

Reference and pointer

Generics

Inference

Loops

Functions

Debugs

Versions

Requirement

Editors

BasicsMy first D program

Types

Arrays

String and characters

Const and Immutable

Input/Output

Algorithm

Structure and Class

Template

Miscellanous

Let start it!

GTK D

Thanks To

Before beginning…

.Tools..

......

Compiler: ldcStandard library: phobosGUI library: gtkd

. .. 40/122.. . . . . . . .. 40/122.

D Programming .

.

.. . . Forward.

.

. ... Back

D Programming

Jonathan MERCIER

IntroductionObject

Functional

Meta-programming

Parallelism

Ressource Management

Contract

System and Safe Code

Reference and pointer

Generics

Inference

Loops

Functions

Debugs

Versions

Requirement

Editors

BasicsMy first D program

Types

Arrays

String and characters

Const and Immutable

Input/Output

Algorithm

Structure and Class

Template

Miscellanous

Let start it!

GTK D

Thanks To

Plan.....1 Introduction

ObjectFunctionalMeta-programmingParallelismRessource ManagementContractSystem and Safe CodeReference and pointerGenericsInferenceLoopsFunctionsDebugsVersionsRequirementEditors

...2 BasicsMy first D programTypesArraysString and charactersConst and ImmutableInput/OutputAlgorithmStructure and ClassTemplateMiscellanousLet start it!

...3 GTK D

...4 Thanks To. .. 41/122.. . . . . . . . .. 41/122.

D Programming .

.

.. . . Forward.

.

. ... Back

D Programming

Jonathan MERCIER

IntroductionObject

Functional

Meta-programming

Parallelism

Ressource Management

Contract

System and Safe Code

Reference and pointer

Generics

Inference

Loops

Functions

Debugs

Versions

Requirement

Editors

BasicsMy first D program

Types

Arrays

String and characters

Const and Immutable

Input/Output

Algorithm

Structure and Class

Template

Miscellanous

Let start it!

GTK D

Thanks To

Editors

.Tools..

......

Geany

MonoDevelop with Mono-DEclipse with DDT - D Development ToolsVim + syntasticEmacs + d-mode (GitHub)

. .. 42/122.. . . . . . . . .. 42/122.

D Programming .

.

.. . . Forward.

.

. ... Back

D Programming

Jonathan MERCIER

IntroductionObject

Functional

Meta-programming

Parallelism

Ressource Management

Contract

System and Safe Code

Reference and pointer

Generics

Inference

Loops

Functions

Debugs

Versions

Requirement

Editors

BasicsMy first D program

Types

Arrays

String and characters

Const and Immutable

Input/Output

Algorithm

Structure and Class

Template

Miscellanous

Let start it!

GTK D

Thanks To

Editors

.Tools..

......

GeanyMonoDevelop with Mono-D

Eclipse with DDT - D Development ToolsVim + syntasticEmacs + d-mode (GitHub)

. .. 42/122.. . . . . . . . .. 42/122.

D Programming .

.

.. . . Forward.

.

. ... Back

D Programming

Jonathan MERCIER

IntroductionObject

Functional

Meta-programming

Parallelism

Ressource Management

Contract

System and Safe Code

Reference and pointer

Generics

Inference

Loops

Functions

Debugs

Versions

Requirement

Editors

BasicsMy first D program

Types

Arrays

String and characters

Const and Immutable

Input/Output

Algorithm

Structure and Class

Template

Miscellanous

Let start it!

GTK D

Thanks To

Editors

.Tools..

......

GeanyMonoDevelop with Mono-DEclipse with DDT - D Development Tools

Vim + syntasticEmacs + d-mode (GitHub)

. .. 42/122.. . . . . . . . .. 42/122.

D Programming .

.

.. . . Forward.

.

. ... Back

D Programming

Jonathan MERCIER

IntroductionObject

Functional

Meta-programming

Parallelism

Ressource Management

Contract

System and Safe Code

Reference and pointer

Generics

Inference

Loops

Functions

Debugs

Versions

Requirement

Editors

BasicsMy first D program

Types

Arrays

String and characters

Const and Immutable

Input/Output

Algorithm

Structure and Class

Template

Miscellanous

Let start it!

GTK D

Thanks To

Editors

.Tools..

......

GeanyMonoDevelop with Mono-DEclipse with DDT - D Development ToolsVim + syntastic

Emacs + d-mode (GitHub)

. .. 42/122.. . . . . . . . .. 42/122.

D Programming .

.

.. . . Forward.

.

. ... Back

D Programming

Jonathan MERCIER

IntroductionObject

Functional

Meta-programming

Parallelism

Ressource Management

Contract

System and Safe Code

Reference and pointer

Generics

Inference

Loops

Functions

Debugs

Versions

Requirement

Editors

BasicsMy first D program

Types

Arrays

String and characters

Const and Immutable

Input/Output

Algorithm

Structure and Class

Template

Miscellanous

Let start it!

GTK D

Thanks To

Editors

.Tools..

......

GeanyMonoDevelop with Mono-DEclipse with DDT - D Development ToolsVim + syntasticEmacs + d-mode (GitHub)

. .. 42/122.. . . . . . . . .. 42/122.

D Programming .

.

.. . . Forward.

.

. ... Back

D Programming

Jonathan MERCIER

IntroductionObject

Functional

Meta-programming

Parallelism

Ressource Management

Contract

System and Safe Code

Reference and pointer

Generics

Inference

Loops

Functions

Debugs

Versions

Requirement

Editors

BasicsMy first D program

Types

Arrays

String and characters

Const and Immutable

Input/Output

Algorithm

Structure and Class

Template

Miscellanous

Let start it!

GTK D

Thanks To

Editors.Online tools: D paste..

......

http://dpaste.dzfl.pl/new

. .. 43/122.. . . . . . . . .. 43/122.

D Programming .

.

.. . . Forward.

.

. ... Back

D Programming

Jonathan MERCIER

IntroductionObject

Functional

Meta-programming

Parallelism

Ressource Management

Contract

System and Safe Code

Reference and pointer

Generics

Inference

Loops

Functions

Debugs

Versions

Requirement

Editors

BasicsMy first D program

Types

Arrays

String and characters

Const and Immutable

Input/Output

Algorithm

Structure and Class

Template

Miscellanous

Let start it!

GTK D

Thanks To

Installation

..

Code 5: Terminal# yum install ldc-phobos-devel gtkd-devel

. .. 44/122.. . . . . . . . .. 44/122.

D Programming .

.

.. . . Forward.

.

. ... Back

D Programming

Jonathan MERCIER

IntroductionObject

Functional

Meta-programming

Parallelism

Ressource Management

Contract

System and Safe Code

Reference and pointer

Generics

Inference

Loops

Functions

Debugs

Versions

Requirement

Editors

BasicsMy first D program

Types

Arrays

String and characters

Const and Immutable

Input/Output

Algorithm

Structure and Class

Template

Miscellanous

Let start it!

GTK D

Thanks To

Plan.....1 Introduction

ObjectFunctionalMeta-programmingParallelismRessource ManagementContractSystem and Safe CodeReference and pointerGenericsInferenceLoopsFunctionsDebugsVersionsRequirementEditors

...2 BasicsMy first D programTypesArraysString and charactersConst and ImmutableInput/OutputAlgorithmStructure and ClassTemplateMiscellanousLet start it!

...3 GTK D

...4 Thanks To. .. 45/122.. . . . . . . . .. 45/122.

D Programming .

.

.. . . Forward.

.

. ... Back

D Programming

Jonathan MERCIER

IntroductionObject

Functional

Meta-programming

Parallelism

Ressource Management

Contract

System and Safe Code

Reference and pointer

Generics

Inference

Loops

Functions

Debugs

Versions

Requirement

Editors

BasicsMy first D program

Types

Arrays

String and characters

Const and Immutable

Input/Output

Algorithm

Structure and Class

Template

Miscellanous

Let start it!

GTK D

Thanks To

My first D program

..

Code 6: hello.d1 module hello; ..2 import std.stdio;34 void main () {5 writeln( ”Hello world” );6 }

.

. .. 46/122.. . . . . . . . . .. 46/122.

D Programming .

.

.. . . Forward.

.

. ... Back

D Programming

Jonathan MERCIER

IntroductionObject

Functional

Meta-programming

Parallelism

Ressource Management

Contract

System and Safe Code

Reference and pointer

Generics

Inference

Loops

Functions

Debugs

Versions

Requirement

Editors

BasicsMy first D program

Types

Arrays

String and characters

Const and Immutable

Input/Output

Algorithm

Structure and Class

Template

Miscellanous

Let start it!

GTK D

Thanks To

My first D program

..

Code 7: hello.d1 module hello;2 import std.stdio; ..34 void main () {5 writeln( ”Hello world” );6 }

.

. .. 47/122.. . . . . . . . . .. 47/122.

D Programming .

.

.. . . Forward.

.

. ... Back

D Programming

Jonathan MERCIER

IntroductionObject

Functional

Meta-programming

Parallelism

Ressource Management

Contract

System and Safe Code

Reference and pointer

Generics

Inference

Loops

Functions

Debugs

Versions

Requirement

Editors

BasicsMy first D program

Types

Arrays

String and characters

Const and Immutable

Input/Output

Algorithm

Structure and Class

Template

Miscellanous

Let start it!

GTK D

Thanks To

My first D program

..

Code 8: hello.d1 module hello;2 import std.stdio: writeln; ..34 void main () {5 writeln( ”Hello world” );6 }

.

. .. 48/122.. . . . . . . . . .. 48/122.

D Programming .

.

.. . . Forward.

.

. ... Back

D Programming

Jonathan MERCIER

IntroductionObject

Functional

Meta-programming

Parallelism

Ressource Management

Contract

System and Safe Code

Reference and pointer

Generics

Inference

Loops

Functions

Debugs

Versions

Requirement

Editors

BasicsMy first D program

Types

Arrays

String and characters

Const and Immutable

Input/Output

Algorithm

Structure and Class

Template

Miscellanous

Let start it!

GTK D

Thanks To

My first D program

..

Code 9: hello.d1 module hello;2 import std.stdio: writeln;34 void main () { ..5 writeln( ”Hello world” );6 }

.

. .. 49/122.. . . . . . . . . .. 49/122.

D Programming .

.

.. . . Forward.

.

. ... Back

D Programming

Jonathan MERCIER

IntroductionObject

Functional

Meta-programming

Parallelism

Ressource Management

Contract

System and Safe Code

Reference and pointer

Generics

Inference

Loops

Functions

Debugs

Versions

Requirement

Editors

BasicsMy first D program

Types

Arrays

String and characters

Const and Immutable

Input/Output

Algorithm

Structure and Class

Template

Miscellanous

Let start it!

GTK D

Thanks To

My first D program

..

Code 10: hello.d1 module hello;2 import std.stdio: writeln;34 void main () {5 writeln( ”Hello world” ); ..6 }

.

. .. 50/122.. . . . . . . . . .. 50/122.

D Programming .

.

.. . . Forward.

.

. ... Back

D Programming

Jonathan MERCIER

IntroductionObject

Functional

Meta-programming

Parallelism

Ressource Management

Contract

System and Safe Code

Reference and pointer

Generics

Inference

Loops

Functions

Debugs

Versions

Requirement

Editors

BasicsMy first D program

Types

Arrays

String and characters

Const and Immutable

Input/Output

Algorithm

Structure and Class

Template

Miscellanous

Let start it!

GTK D

Thanks To

..

Code 11: Terminal$ ldc2 hello.d$ ./helloHello world

. .. 51/122.. . . . . . . . . . .. 51/122.

D Programming .

.

.. . . Forward.

.

. ... Back

D Programming

Jonathan MERCIER

IntroductionObject

Functional

Meta-programming

Parallelism

Ressource Management

Contract

System and Safe Code

Reference and pointer

Generics

Inference

Loops

Functions

Debugs

Versions

Requirement

Editors

BasicsMy first D program

Types

Arrays

String and characters

Const and Immutable

Input/Output

Algorithm

Structure and Class

Template

Miscellanous

Let start it!

GTK D

Thanks To

Plan.....1 Introduction

ObjectFunctionalMeta-programmingParallelismRessource ManagementContractSystem and Safe CodeReference and pointerGenericsInferenceLoopsFunctionsDebugsVersionsRequirementEditors

...2 BasicsMy first D programTypesArraysString and charactersConst and ImmutableInput/OutputAlgorithmStructure and ClassTemplateMiscellanousLet start it!

...3 GTK D

...4 Thanks To. .. 52/122.. . . . . . . . . . .. 52/122.

D Programming .

.

.. . . Forward.

.

. ... Back

D Programming

Jonathan MERCIER

IntroductionObject

Functional

Meta-programming

Parallelism

Ressource Management

Contract

System and Safe Code

Reference and pointer

Generics

Inference

Loops

Functions

Debugs

Versions

Requirement

Editors

BasicsMy first D program

Types

Arrays

String and characters

Const and Immutable

Input/Output

Algorithm

Structure and Class

Template

Miscellanous

Let start it!

GTK D

Thanks To

TypesType bits Minimum Maximum

void Not available Not available Not availablebyte 8 -128 127short 16 -32768 32767int 32 -2147483648 2147483647long 64 -9223372036854775808 9223372036854775807ubyte 8 0 255ushort 16 0 65535uint 32 0 4294967296ulong 64 0 18446744073709551615float 32 1.18e-38 3.40e+38

double 64 2.23e-308 1.80e+308

ifloat 32 1.18e-38 3.40e+38

idouble 64 2.23e-308 1.80e+308

cfloat 32 1.18e-38 3.40e+38

cdouble 64 2.23e-308 1.80e+308

real 128 3.36e-4932 1.19e+4932

ireal 128 3.36e-4932 1.19e+4932

creal 28 3.36e-4932 1.19e+4932

char utf-8: 8 0 255wchar utf-16: 16 0 65535dchar utf-32: 32 0 4294967293bool 8 false true

. .. 53/122.. . . . . . . . . . .. 53/122.

D Programming .

.

.. . . Forward.

.

. ... Back

D Programming

Jonathan MERCIER

IntroductionObject

Functional

Meta-programming

Parallelism

Ressource Management

Contract

System and Safe Code

Reference and pointer

Generics

Inference

Loops

Functions

Debugs

Versions

Requirement

Editors

BasicsMy first D program

Types

Arrays

String and characters

Const and Immutable

Input/Output

Algorithm

Structure and Class

Template

Miscellanous

Let start it!

GTK D

Thanks To

Plan.....1 Introduction

ObjectFunctionalMeta-programmingParallelismRessource ManagementContractSystem and Safe CodeReference and pointerGenericsInferenceLoopsFunctionsDebugsVersionsRequirementEditors

...2 BasicsMy first D programTypesArraysString and charactersConst and ImmutableInput/OutputAlgorithmStructure and ClassTemplateMiscellanousLet start it!

...3 GTK D

...4 Thanks To. .. 54/122.. . . . . . . . . . .. 54/122.

D Programming .

.

.. . . Forward.

.

. ... Back

D Programming

Jonathan MERCIER

IntroductionObject

Functional

Meta-programming

Parallelism

Ressource Management

Contract

System and Safe Code

Reference and pointer

Generics

Inference

Loops

Functions

Debugs

Versions

Requirement

Editors

BasicsMy first D program

Types

Arrays

String and characters

Const and Immutable

Input/Output

Algorithm

Structure and Class

Template

Miscellanous

Let start it!

GTK D

Thanks To

Static arrays

..

1 int[3] a1 = [ 0, 1, 2 ]; ..2 int[3][3] a2 = [ [ 0, 1, 2, 3 ], [ 4, 5, 6 ], [ 7, 8, 9 ] ];3 a1.length;

.

. .. 55/122.. . . . . . . . . . .. 55/122.

D Programming .

.

.. . . Forward.

.

. ... Back

D Programming

Jonathan MERCIER

IntroductionObject

Functional

Meta-programming

Parallelism

Ressource Management

Contract

System and Safe Code

Reference and pointer

Generics

Inference

Loops

Functions

Debugs

Versions

Requirement

Editors

BasicsMy first D program

Types

Arrays

String and characters

Const and Immutable

Input/Output

Algorithm

Structure and Class

Template

Miscellanous

Let start it!

GTK D

Thanks To

Static arrays

..

1 int[3] a1 = [ 0, 1, 2 ];2 int[3][3] a2 = [ [ 0, 1, 2, 3 ], [ 4, 5, 6 ], [ 7, 8, 9 ] ]; ..3 a1.length;

.

. .. 56/122.. . . . . . . . . . . .. 56/122.

D Programming .

.

.. . . Forward.

.

. ... Back

D Programming

Jonathan MERCIER

IntroductionObject

Functional

Meta-programming

Parallelism

Ressource Management

Contract

System and Safe Code

Reference and pointer

Generics

Inference

Loops

Functions

Debugs

Versions

Requirement

Editors

BasicsMy first D program

Types

Arrays

String and characters

Const and Immutable

Input/Output

Algorithm

Structure and Class

Template

Miscellanous

Let start it!

GTK D

Thanks To

Static arrays

..

1 int[3] a1 = [ 0, 1, 2 ];2 int[3][3] a2 = [ [ 0, 1, 2, 3 ], [ 4, 5, 6 ], [ 7, 8, 9 ] ];3 a1.length; // return array size ..

.

. .. 57/122.. . . . . . . . . . . .. 57/122.

D Programming .

.

.. . . Forward.

.

. ... Back

D Programming

Jonathan MERCIER

IntroductionObject

Functional

Meta-programming

Parallelism

Ressource Management

Contract

System and Safe Code

Reference and pointer

Generics

Inference

Loops

Functions

Debugs

Versions

Requirement

Editors

BasicsMy first D program

Types

Arrays

String and characters

Const and Immutable

Input/Output

Algorithm

Structure and Class

Template

Miscellanous

Let start it!

GTK D

Thanks To

Dynamic arrays

..

1 int[] a1 = [ 0, 1, 2 ]; ..2 a1.length;3 a1.length = a1.length + 2;4 a1.length += 2;

.

. .. 58/122.. . . . . . . . . . . .. 58/122.

D Programming .

.

.. . . Forward.

.

. ... Back

D Programming

Jonathan MERCIER

IntroductionObject

Functional

Meta-programming

Parallelism

Ressource Management

Contract

System and Safe Code

Reference and pointer

Generics

Inference

Loops

Functions

Debugs

Versions

Requirement

Editors

BasicsMy first D program

Types

Arrays

String and characters

Const and Immutable

Input/Output

Algorithm

Structure and Class

Template

Miscellanous

Let start it!

GTK D

Thanks To

Dynamic arrays

..

1 int[] a1 = [ 0, 1, 2 ];2 a1.length; // return array size ..3 a1.length = a1.length + 2;4 a1.length += 2;

.

. .. 59/122.. . . . . . . . . . . .. 59/122.

D Programming .

.

.. . . Forward.

.

. ... Back

D Programming

Jonathan MERCIER

IntroductionObject

Functional

Meta-programming

Parallelism

Ressource Management

Contract

System and Safe Code

Reference and pointer

Generics

Inference

Loops

Functions

Debugs

Versions

Requirement

Editors

BasicsMy first D program

Types

Arrays

String and characters

Const and Immutable

Input/Output

Algorithm

Structure and Class

Template

Miscellanous

Let start it!

GTK D

Thanks To

Dynamic arrays

..

1 int[] a1 = [ 0, 1, 2 ];2 a1.length;3 a1.length = a1.length + 2; // resize array ..4 a1.length += 2;

.

. .. 60/122.. . . . . . . . . . . .. 60/122.

D Programming .

.

.. . . Forward.

.

. ... Back

D Programming

Jonathan MERCIER

IntroductionObject

Functional

Meta-programming

Parallelism

Ressource Management

Contract

System and Safe Code

Reference and pointer

Generics

Inference

Loops

Functions

Debugs

Versions

Requirement

Editors

BasicsMy first D program

Types

Arrays

String and characters

Const and Immutable

Input/Output

Algorithm

Structure and Class

Template

Miscellanous

Let start it!

GTK D

Thanks To

Dynamic arrays

..

1 int[] a1 = [ 0, 1, 2 ];2 a1.length;3 a1.length = a1.length + 2;4 a1.length += 2; // not allowed ..

.

. .. 61/122.. . . . . . . . . . . . .. 61/122.

D Programming .

.

.. . . Forward.

.

. ... Back

D Programming

Jonathan MERCIER

IntroductionObject

Functional

Meta-programming

Parallelism

Ressource Management

Contract

System and Safe Code

Reference and pointer

Generics

Inference

Loops

Functions

Debugs

Versions

Requirement

Editors

BasicsMy first D program

Types

Arrays

String and characters

Const and Immutable

Input/Output

Algorithm

Structure and Class

Template

Miscellanous

Let start it!

GTK D

Thanks To

Matrix arrays

..1 int[][] a1 = new int[][](2,5); // [[0, 0, 0, 0, 0], [0, 0, 0, 0, 0]]2 int [][] a2 = [ [ 1, 2, 3 ], [ 4, 5, 6 ], [ 7, 8, 9 ] ];

. .. 62/122.. . . . . . . . . . . . .. 62/122.

D Programming .

.

.. . . Forward.

.

. ... Back

D Programming

Jonathan MERCIER

IntroductionObject

Functional

Meta-programming

Parallelism

Ressource Management

Contract

System and Safe Code

Reference and pointer

Generics

Inference

Loops

Functions

Debugs

Versions

Requirement

Editors

BasicsMy first D program

Types

Arrays

String and characters

Const and Immutable

Input/Output

Algorithm

Structure and Class

Template

Miscellanous

Let start it!

GTK D

Thanks To

Arrays

..

1 int[] a1 = [ 0, 1, 2 ]; ..2 a1[0];3 a1[0..2];4 a1[0..$];

.

. .. 63/122.. . . . . . . . . . . . .. 63/122.

D Programming .

.

.. . . Forward.

.

. ... Back

D Programming

Jonathan MERCIER

IntroductionObject

Functional

Meta-programming

Parallelism

Ressource Management

Contract

System and Safe Code

Reference and pointer

Generics

Inference

Loops

Functions

Debugs

Versions

Requirement

Editors

BasicsMy first D program

Types

Arrays

String and characters

Const and Immutable

Input/Output

Algorithm

Structure and Class

Template

Miscellanous

Let start it!

GTK D

Thanks To

Arrays

..

1 int[] a1 = [ 0, 1, 2 ];2 a1[0]; // return 0 ..3 a1[0..2];4 a1[0..$];

.

. .. 64/122.. . . . . . . . . . . . .. 64/122.

D Programming .

.

.. . . Forward.

.

. ... Back

D Programming

Jonathan MERCIER

IntroductionObject

Functional

Meta-programming

Parallelism

Ressource Management

Contract

System and Safe Code

Reference and pointer

Generics

Inference

Loops

Functions

Debugs

Versions

Requirement

Editors

BasicsMy first D program

Types

Arrays

String and characters

Const and Immutable

Input/Output

Algorithm

Structure and Class

Template

Miscellanous

Let start it!

GTK D

Thanks To

Arrays

..

1 int[] a1 = [ 0, 1, 2 ];2 a1[0];3 a1[0..2]; // return [0, 1] ..4 a1[0..$];

.

. .. 65/122.. . . . . . . . . . . . .. 65/122.

D Programming .

.

.. . . Forward.

.

. ... Back

D Programming

Jonathan MERCIER

IntroductionObject

Functional

Meta-programming

Parallelism

Ressource Management

Contract

System and Safe Code

Reference and pointer

Generics

Inference

Loops

Functions

Debugs

Versions

Requirement

Editors

BasicsMy first D program

Types

Arrays

String and characters

Const and Immutable

Input/Output

Algorithm

Structure and Class

Template

Miscellanous

Let start it!

GTK D

Thanks To

Arrays

..

1 int[] a1 = [ 0, 1, 2 ];2 a1[0];3 a1[0..2];4 a1[0..$]; // return [0, 1, 2] ..

.

. .. 66/122.. . . . . . . . . . . . . .. 66/122.

D Programming .

.

.. . . Forward.

.

. ... Back

D Programming

Jonathan MERCIER

IntroductionObject

Functional

Meta-programming

Parallelism

Ressource Management

Contract

System and Safe Code

Reference and pointer

Generics

Inference

Loops

Functions

Debugs

Versions

Requirement

Editors

BasicsMy first D program

Types

Arrays

String and characters

Const and Immutable

Input/Output

Algorithm

Structure and Class

Template

Miscellanous

Let start it!

GTK D

Thanks To

Arrays

..

1 int[] a = [ 0, 1, 2 ];2 int[] b = a; // ’b’ point to ’a’ (reference) ..3 int* b_ptr = b.ptr;4 int[] c = a[ 0 .. 2 ];5 int[] d = a[ 0 .. 2 ].dup;

.

. .. 67/122.. . . . . . . . . . . . . .. 67/122.

D Programming .

.

.. . . Forward.

.

. ... Back

D Programming

Jonathan MERCIER

IntroductionObject

Functional

Meta-programming

Parallelism

Ressource Management

Contract

System and Safe Code

Reference and pointer

Generics

Inference

Loops

Functions

Debugs

Versions

Requirement

Editors

BasicsMy first D program

Types

Arrays

String and characters

Const and Immutable

Input/Output

Algorithm

Structure and Class

Template

Miscellanous

Let start it!

GTK D

Thanks To

Arrays

..

1 int[] a = [ 0, 1, 2 ];2 int[] b = a;3 int* b_ptr = b.ptr; // return pointer to given array ..4 int[] c = a[ 0 .. 2 ];5 int[] d = a[ 0 .. 2 ].dup;

.

. .. 68/122.. . . . . . . . . . . . . .. 68/122.

D Programming .

.

.. . . Forward.

.

. ... Back

D Programming

Jonathan MERCIER

IntroductionObject

Functional

Meta-programming

Parallelism

Ressource Management

Contract

System and Safe Code

Reference and pointer

Generics

Inference

Loops

Functions

Debugs

Versions

Requirement

Editors

BasicsMy first D program

Types

Arrays

String and characters

Const and Immutable

Input/Output

Algorithm

Structure and Class

Template

Miscellanous

Let start it!

GTK D

Thanks To

Arrays

..

1 int[] a = [ 0, 1, 2 ];2 int[] b = a;3 int* b_ptr = b.ptr;4 int[] c = a[ 0 .. 2 ]; // is a reference ..5 int[] d = a[ 0 .. 2 ].dup;

.

. .. 69/122.. . . . . . . . . . . . . .. 69/122.

D Programming .

.

.. . . Forward.

.

. ... Back

D Programming

Jonathan MERCIER

IntroductionObject

Functional

Meta-programming

Parallelism

Ressource Management

Contract

System and Safe Code

Reference and pointer

Generics

Inference

Loops

Functions

Debugs

Versions

Requirement

Editors

BasicsMy first D program

Types

Arrays

String and characters

Const and Immutable

Input/Output

Algorithm

Structure and Class

Template

Miscellanous

Let start it!

GTK D

Thanks To

Arrays

..

1 int[] a = [ 0, 1, 2 ];2 int[] b = a;3 int* b_ptr = b.ptr;4 int[] c = a[ 0 .. 2 ];5 int[] d = a[ 0 .. 2 ].dup; // is a copy ..

.

. .. 70/122.. . . . . . . . . . . . . .. 70/122.

D Programming .

.

.. . . Forward.

.

. ... Back

D Programming

Jonathan MERCIER

IntroductionObject

Functional

Meta-programming

Parallelism

Ressource Management

Contract

System and Safe Code

Reference and pointer

Generics

Inference

Loops

Functions

Debugs

Versions

Requirement

Editors

BasicsMy first D program

Types

Arrays

String and characters

Const and Immutable

Input/Output

Algorithm

Structure and Class

Template

Miscellanous

Let start it!

GTK D

Thanks To

Vectors

..

1 int[] a1 = new int[](2); // [0,0]..2 a1[] = 1;3 a1[]+= 2;

.

. .. 71/122.. . . . . . . . . . . . . . .. 71/122.

D Programming .

.

.. . . Forward.

.

. ... Back

D Programming

Jonathan MERCIER

IntroductionObject

Functional

Meta-programming

Parallelism

Ressource Management

Contract

System and Safe Code

Reference and pointer

Generics

Inference

Loops

Functions

Debugs

Versions

Requirement

Editors

BasicsMy first D program

Types

Arrays

String and characters

Const and Immutable

Input/Output

Algorithm

Structure and Class

Template

Miscellanous

Let start it!

GTK D

Thanks To

Vectors

..

1 int[] a1 = new int[](2);2 a1[] = 1; // [1,1]..3 a1[]+= 2;

.

. .. 72/122.. . . . . . . . . . . . . . .. 72/122.

D Programming .

.

.. . . Forward.

.

. ... Back

D Programming

Jonathan MERCIER

IntroductionObject

Functional

Meta-programming

Parallelism

Ressource Management

Contract

System and Safe Code

Reference and pointer

Generics

Inference

Loops

Functions

Debugs

Versions

Requirement

Editors

BasicsMy first D program

Types

Arrays

String and characters

Const and Immutable

Input/Output

Algorithm

Structure and Class

Template

Miscellanous

Let start it!

GTK D

Thanks To

Vectors

..

1 int[] a1 = new int[](2);2 a1[] = 1;3 a1[]+= 2; // [3,3] ..

.

. .. 73/122.. . . . . . . . . . . . . . .. 73/122.

D Programming .

.

.. . . Forward.

.

. ... Back

D Programming

Jonathan MERCIER

IntroductionObject

Functional

Meta-programming

Parallelism

Ressource Management

Contract

System and Safe Code

Reference and pointer

Generics

Inference

Loops

Functions

Debugs

Versions

Requirement

Editors

BasicsMy first D program

Types

Arrays

String and characters

Const and Immutable

Input/Output

Algorithm

Structure and Class

Template

Miscellanous

Let start it!

GTK D

Thanks To

Associative arrays

..

1 int[string] dict; ..2 dict[”D”] = 1;3 ”D” in dict;

.

. .. 74/122.. . . . . . . . . . . . . . .. 74/122.

D Programming .

.

.. . . Forward.

.

. ... Back

D Programming

Jonathan MERCIER

IntroductionObject

Functional

Meta-programming

Parallelism

Ressource Management

Contract

System and Safe Code

Reference and pointer

Generics

Inference

Loops

Functions

Debugs

Versions

Requirement

Editors

BasicsMy first D program

Types

Arrays

String and characters

Const and Immutable

Input/Output

Algorithm

Structure and Class

Template

Miscellanous

Let start it!

GTK D

Thanks To

Associative arrays

..

1 int[string] dict;2 dict[”D”] = 1; ..3 ”D” in dict;

.

. .. 75/122.. . . . . . . . . . . . . . .. 75/122.

D Programming .

.

.. . . Forward.

.

. ... Back

D Programming

Jonathan MERCIER

IntroductionObject

Functional

Meta-programming

Parallelism

Ressource Management

Contract

System and Safe Code

Reference and pointer

Generics

Inference

Loops

Functions

Debugs

Versions

Requirement

Editors

BasicsMy first D program

Types

Arrays

String and characters

Const and Immutable

Input/Output

Algorithm

Structure and Class

Template

Miscellanous

Let start it!

GTK D

Thanks To

Associative arrays

..

1 int[string] dict;2 dict[”D”] = 1;3 ”D” in dict; // true ..

.

. .. 76/122.. . . . . . . . . . . . . . . .. 76/122.

D Programming .

.

.. . . Forward.

.

. ... Back

D Programming

Jonathan MERCIER

IntroductionObject

Functional

Meta-programming

Parallelism

Ressource Management

Contract

System and Safe Code

Reference and pointer

Generics

Inference

Loops

Functions

Debugs

Versions

Requirement

Editors

BasicsMy first D program

Types

Arrays

String and characters

Const and Immutable

Input/Output

Algorithm

Structure and Class

Template

Miscellanous

Let start it!

GTK D

Thanks To

Plan.....1 Introduction

ObjectFunctionalMeta-programmingParallelismRessource ManagementContractSystem and Safe CodeReference and pointerGenericsInferenceLoopsFunctionsDebugsVersionsRequirementEditors

...2 BasicsMy first D programTypesArraysString and charactersConst and ImmutableInput/OutputAlgorithmStructure and ClassTemplateMiscellanousLet start it!

...3 GTK D

...4 Thanks To. .. 77/122.. . . . . . . . . . . . . . . .. 77/122.

D Programming .

.

.. . . Forward.

.

. ... Back

D Programming

Jonathan MERCIER

IntroductionObject

Functional

Meta-programming

Parallelism

Ressource Management

Contract

System and Safe Code

Reference and pointer

Generics

Inference

Loops

Functions

Debugs

Versions

Requirement

Editors

BasicsMy first D program

Types

Arrays

String and characters

Const and Immutable

Input/Output

Algorithm

Structure and Class

Template

Miscellanous

Let start it!

GTK D

Thanks To

String and characters

..

1 string words = ”With double quote, αβγδϵ”; // UTF−82 string words2= words ~ ”, and concatenation”; // concat3 char letter= ’a’; // simple quote

. .. 78/122.. . . . . . . . . . . . . . . .. 78/122.

D Programming .

.

.. . . Forward.

.

. ... Back

D Programming

Jonathan MERCIER

IntroductionObject

Functional

Meta-programming

Parallelism

Ressource Management

Contract

System and Safe Code

Reference and pointer

Generics

Inference

Loops

Functions

Debugs

Versions

Requirement

Editors

BasicsMy first D program

Types

Arrays

String and characters

Const and Immutable

Input/Output

Algorithm

Structure and Class

Template

Miscellanous

Let start it!

GTK D

Thanks To

Plan.....1 Introduction

ObjectFunctionalMeta-programmingParallelismRessource ManagementContractSystem and Safe CodeReference and pointerGenericsInferenceLoopsFunctionsDebugsVersionsRequirementEditors

...2 BasicsMy first D programTypesArraysString and charactersConst and ImmutableInput/OutputAlgorithmStructure and ClassTemplateMiscellanousLet start it!

...3 GTK D

...4 Thanks To. .. 79/122.. . . . . . . . . . . . . . . .. 79/122.

D Programming .

.

.. . . Forward.

.

. ... Back

D Programming

Jonathan MERCIER

IntroductionObject

Functional

Meta-programming

Parallelism

Ressource Management

Contract

System and Safe Code

Reference and pointer

Generics

Inference

Loops

Functions

Debugs

Versions

Requirement

Editors

BasicsMy first D program

Types

Arrays

String and characters

Const and Immutable

Input/Output

Algorithm

Structure and Class

Template

Miscellanous

Let start it!

GTK D

Thanks To

Const and Immutable

.Const and Immutable..

......

im­mutable data: that can­not change.const data: can­not be changedby the current const ref­er­ence to that data.

. .. 80/122.. . . . . . . . . . . . . . . .. 80/122.

D Programming .

.

.. . . Forward.

.

. ... Back

D Programming

Jonathan MERCIER

IntroductionObject

Functional

Meta-programming

Parallelism

Ressource Management

Contract

System and Safe Code

Reference and pointer

Generics

Inference

Loops

Functions

Debugs

Versions

Requirement

Editors

BasicsMy first D program

Types

Arrays

String and characters

Const and Immutable

Input/Output

Algorithm

Structure and Class

Template

Miscellanous

Let start it!

GTK D

Thanks To

Plan.....1 Introduction

ObjectFunctionalMeta-programmingParallelismRessource ManagementContractSystem and Safe CodeReference and pointerGenericsInferenceLoopsFunctionsDebugsVersionsRequirementEditors

...2 BasicsMy first D programTypesArraysString and charactersConst and ImmutableInput/OutputAlgorithmStructure and ClassTemplateMiscellanousLet start it!

...3 GTK D

...4 Thanks To. .. 81/122.. . . . . . . . . . . . . . . . .. 81/122.

D Programming .

.

.. . . Forward.

.

. ... Back

D Programming

Jonathan MERCIER

IntroductionObject

Functional

Meta-programming

Parallelism

Ressource Management

Contract

System and Safe Code

Reference and pointer

Generics

Inference

Loops

Functions

Debugs

Versions

Requirement

Editors

BasicsMy first D program

Types

Arrays

String and characters

Const and Immutable

Input/Output

Algorithm

Structure and Class

Template

Miscellanous

Let start it!

GTK D

Thanks To

Input/Output

..

Code 12: Read a file1 import std.stdio: open, writeln;2 …3 File f = open( ”/path/to/myFile”, ”r” );4 scope(exit) f.close;5 foreach( number, line; f )6 writeln( number, line );7 …

. .. 82/122.. . . . . . . . . . . . . . . . .. 82/122.

D Programming .

.

.. . . Forward.

.

. ... Back

D Programming

Jonathan MERCIER

IntroductionObject

Functional

Meta-programming

Parallelism

Ressource Management

Contract

System and Safe Code

Reference and pointer

Generics

Inference

Loops

Functions

Debugs

Versions

Requirement

Editors

BasicsMy first D program

Types

Arrays

String and characters

Const and Immutable

Input/Output

Algorithm

Structure and Class

Template

Miscellanous

Let start it!

GTK D

Thanks To

Input/Output

..

Code 13: Write a file1 import std.stdio: open, writeln;2 …3 File f = open( ”/path/to/myFile”, ”w” );4 scope(exit) f.close;5 writeln( ”something” );6 …

. .. 83/122.. . . . . . . . . . . . . . . . .. 83/122.

D Programming .

.

.. . . Forward.

.

. ... Back

D Programming

Jonathan MERCIER

IntroductionObject

Functional

Meta-programming

Parallelism

Ressource Management

Contract

System and Safe Code

Reference and pointer

Generics

Inference

Loops

Functions

Debugs

Versions

Requirement

Editors

BasicsMy first D program

Types

Arrays

String and characters

Const and Immutable

Input/Output

Algorithm

Structure and Class

Template

Miscellanous

Let start it!

GTK D

Thanks To

Input/Output

..

Code 14: Capture keyboard1 import std.stdio: open, writeln;2 …3 char[] name;4 size_t age;5 write( ”Enter your name : ” );6 readf( ”%s” ~ newline, &name );7 write( ”How old are you : ” );8 readf( ”%u” ~ newline, &age );9 …

. .. 84/122.. . . . . . . . . . . . . . . . .. 84/122.

D Programming .

.

.. . . Forward.

.

. ... Back

D Programming

Jonathan MERCIER

IntroductionObject

Functional

Meta-programming

Parallelism

Ressource Management

Contract

System and Safe Code

Reference and pointer

Generics

Inference

Loops

Functions

Debugs

Versions

Requirement

Editors

BasicsMy first D program

Types

Arrays

String and characters

Const and Immutable

Input/Output

Algorithm

Structure and Class

Template

Miscellanous

Let start it!

GTK D

Thanks To

Plan.....1 Introduction

ObjectFunctionalMeta-programmingParallelismRessource ManagementContractSystem and Safe CodeReference and pointerGenericsInferenceLoopsFunctionsDebugsVersionsRequirementEditors

...2 BasicsMy first D programTypesArraysString and charactersConst and ImmutableInput/OutputAlgorithmStructure and ClassTemplateMiscellanousLet start it!

...3 GTK D

...4 Thanks To. .. 85/122.. . . . . . . . . . . . . . . . .. 85/122.

D Programming .

.

.. . . Forward.

.

. ... Back

D Programming

Jonathan MERCIER

IntroductionObject

Functional

Meta-programming

Parallelism

Ressource Management

Contract

System and Safe Code

Reference and pointer

Generics

Inference

Loops

Functions

Debugs

Versions

Requirement

Editors

BasicsMy first D program

Types

Arrays

String and characters

Const and Immutable

Input/Output

Algorithm

Structure and Class

Template

Miscellanous

Let start it!

GTK D

Thanks To

Algorithm

..

Code 15: Searching1 import std.algorihm: count, countUntil, startsWith, endsWith,

canFind;2 …3 int[] list = [ 0, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9 ]; ..4 list.count( 1 );5 list.countUntil( 2 );6 list.startsWith( 0 );7 list.endsWith( 9 );8 list.canFind( 2 );

.

. .. 86/122.. . . . . . . . . . . . . . . . . .. 86/122.

D Programming .

.

.. . . Forward.

.

. ... Back

D Programming

Jonathan MERCIER

IntroductionObject

Functional

Meta-programming

Parallelism

Ressource Management

Contract

System and Safe Code

Reference and pointer

Generics

Inference

Loops

Functions

Debugs

Versions

Requirement

Editors

BasicsMy first D program

Types

Arrays

String and characters

Const and Immutable

Input/Output

Algorithm

Structure and Class

Template

Miscellanous

Let start it!

GTK D

Thanks To

Algorithm

..

Code 16: Searching1 import std.algorihm: count, countUntil, startsWith, endsWith,

canFind;2 …3 int[] list = [ 0, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9 ];4 list.count( 1 ); // result => 2 ..5 list.countUntil( 2 );6 list.startsWith( 0 );7 list.endsWith( 9 );8 list.canFind( 2 );

.

. .. 87/122.. . . . . . . . . . . . . . . . . .. 87/122.

D Programming .

.

.. . . Forward.

.

. ... Back

D Programming

Jonathan MERCIER

IntroductionObject

Functional

Meta-programming

Parallelism

Ressource Management

Contract

System and Safe Code

Reference and pointer

Generics

Inference

Loops

Functions

Debugs

Versions

Requirement

Editors

BasicsMy first D program

Types

Arrays

String and characters

Const and Immutable

Input/Output

Algorithm

Structure and Class

Template

Miscellanous

Let start it!

GTK D

Thanks To

Algorithm

..

Code 17: Searching1 import std.algorihm: count, countUntil, startsWith, endsWith,

canFind;2 …3 int[] list = [ 0, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9 ];4 list.count( 1 );5 list.countUntil( 2 ); // result => 3 ..6 list.startsWith( 0 );7 list.endsWith( 9 );8 list.canFind( 2 );

.

. .. 88/122.. . . . . . . . . . . . . . . . . .. 88/122.

D Programming .

.

.. . . Forward.

.

. ... Back

D Programming

Jonathan MERCIER

IntroductionObject

Functional

Meta-programming

Parallelism

Ressource Management

Contract

System and Safe Code

Reference and pointer

Generics

Inference

Loops

Functions

Debugs

Versions

Requirement

Editors

BasicsMy first D program

Types

Arrays

String and characters

Const and Immutable

Input/Output

Algorithm

Structure and Class

Template

Miscellanous

Let start it!

GTK D

Thanks To

Algorithm

..

Code 18: Searching1 import std.algorihm: count, countUntil, startsWith, endsWith,

canFind;2 …3 int[] list = [ 0, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9 ];4 list.count( 1 );5 list.countUntil( 2 );6 list.startsWith( 0 ); // result => true ..7 list.endsWith( 9 );8 list.canFind( 2 );

.

. .. 89/122.. . . . . . . . . . . . . . . . . .. 89/122.

D Programming .

.

.. . . Forward.

.

. ... Back

D Programming

Jonathan MERCIER

IntroductionObject

Functional

Meta-programming

Parallelism

Ressource Management

Contract

System and Safe Code

Reference and pointer

Generics

Inference

Loops

Functions

Debugs

Versions

Requirement

Editors

BasicsMy first D program

Types

Arrays

String and characters

Const and Immutable

Input/Output

Algorithm

Structure and Class

Template

Miscellanous

Let start it!

GTK D

Thanks To

Algorithm

..

Code 19: Searching1 import std.algorihm: count, countUntil, startsWith, endsWith,

canFind;2 …3 int[] list = [ 0, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9 ];4 list.count( 1 );5 list.countUntil( 2 );6 list.startsWith( 0 );7 list.endsWith( 9 ); // result => true ..8 list.canFind( 2 );

.

. .. 90/122.. . . . . . . . . . . . . . . . . .. 90/122.

D Programming .

.

.. . . Forward.

.

. ... Back

D Programming

Jonathan MERCIER

IntroductionObject

Functional

Meta-programming

Parallelism

Ressource Management

Contract

System and Safe Code

Reference and pointer

Generics

Inference

Loops

Functions

Debugs

Versions

Requirement

Editors

BasicsMy first D program

Types

Arrays

String and characters

Const and Immutable

Input/Output

Algorithm

Structure and Class

Template

Miscellanous

Let start it!

GTK D

Thanks To

Algorithm

..

Code 20: Searching1 import std.algorihm: count, countUntil, startsWith, endsWith,

canFind;2 …3 int[] list = [ 0, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9 ];4 list.count( 1 );5 list.countUntil( 2 );6 list.startsWith( 0 );7 list.endsWith( 9 );8 list.canFind( 2 ); // result => true ..

.

. .. 91/122.. . . . . . . . . . . . . . . . . . .. 91/122.

D Programming .

.

.. . . Forward.

.

. ... Back

D Programming

Jonathan MERCIER

IntroductionObject

Functional

Meta-programming

Parallelism

Ressource Management

Contract

System and Safe Code

Reference and pointer

Generics

Inference

Loops

Functions

Debugs

Versions

Requirement

Editors

BasicsMy first D program

Types

Arrays

String and characters

Const and Immutable

Input/Output

Algorithm

Structure and Class

Template

Miscellanous

Let start it!

GTK D

Thanks To

Algorithm

..

Code 21: Comparison1 import std.algorihm: min, max;2 …3 min( 9, 12); // result => 94 max( 9, 12); // result => 12

. .. 92/122.. . . . . . . . . . . . . . . . . . .. 92/122.

D Programming .

.

.. . . Forward.

.

. ... Back

D Programming

Jonathan MERCIER

IntroductionObject

Functional

Meta-programming

Parallelism

Ressource Management

Contract

System and Safe Code

Reference and pointer

Generics

Inference

Loops

Functions

Debugs

Versions

Requirement

Editors

BasicsMy first D program

Types

Arrays

String and characters

Const and Immutable

Input/Output

Algorithm

Structure and Class

Template

Miscellanous

Let start it!

GTK D

Thanks To

Algorithm

..

Code 22: Iteration1 import std.algorihm: filter, uniq, map, reduce;2 int[] list = [ 0, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9 ]; ..3 list.filter!( a => a > 6 );4 list.uniq( );5 list.map!( a => a + 2 );6 0.reduce!( (a,b) => a + b )( list );7 list.reduce!( min, max )( );

.

. .. 93/122.. . . . . . . . . . . . . . . . . . .. 93/122.

D Programming .

.

.. . . Forward.

.

. ... Back

D Programming

Jonathan MERCIER

IntroductionObject

Functional

Meta-programming

Parallelism

Ressource Management

Contract

System and Safe Code

Reference and pointer

Generics

Inference

Loops

Functions

Debugs

Versions

Requirement

Editors

BasicsMy first D program

Types

Arrays

String and characters

Const and Immutable

Input/Output

Algorithm

Structure and Class

Template

Miscellanous

Let start it!

GTK D

Thanks To

Algorithm

..

Code 23: Iteration1 import std.algorihm: filter, uniq, map, reduce;2 int[] list = [ 0, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9 ];3 list.filter!( a => a > 6 ); // result => [ 7, 8, 9 ] ..4 list.uniq( );5 list.map!( a => a + 2 );6 0.reduce!( (a,b) => a + b )( list );7 list.reduce!( min, max )( );

.

. .. 94/122.. . . . . . . . . . . . . . . . . . .. 94/122.

D Programming .

.

.. . . Forward.

.

. ... Back

D Programming

Jonathan MERCIER

IntroductionObject

Functional

Meta-programming

Parallelism

Ressource Management

Contract

System and Safe Code

Reference and pointer

Generics

Inference

Loops

Functions

Debugs

Versions

Requirement

Editors

BasicsMy first D program

Types

Arrays

String and characters

Const and Immutable

Input/Output

Algorithm

Structure and Class

Template

Miscellanous

Let start it!

GTK D

Thanks To

Algorithm

..

Code 24: Iteration1 import std.algorihm: filter, uniq, map, reduce;2 int[] list = [ 0, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9 ];3 list.filter!( a => a > 6 );4 list.uniq( ); // [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 ] ..5 list.map!( a => a + 2 );6 0.reduce!( (a,b) => a + b )( list );7 list.reduce!( min, max )( );

.

. .. 95/122.. . . . . . . . . . . . . . . . . . .. 95/122.

D Programming .

.

.. . . Forward.

.

. ... Back

D Programming

Jonathan MERCIER

IntroductionObject

Functional

Meta-programming

Parallelism

Ressource Management

Contract

System and Safe Code

Reference and pointer

Generics

Inference

Loops

Functions

Debugs

Versions

Requirement

Editors

BasicsMy first D program

Types

Arrays

String and characters

Const and Immutable

Input/Output

Algorithm

Structure and Class

Template

Miscellanous

Let start it!

GTK D

Thanks To

Algorithm

..

Code 25: Iteration1 import std.algorihm: filter, uniq, map, reduce;2 int[] list = [ 0, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9 ];3 list.filter!( a => a > 6 );4 list.uniq( );5 list.map!( a => a + 2 ); // [ 2, 3, 3, 4, 5, 6, 7, 8, 9, 10, 11 ] ..6 0.reduce!( (a,b) => a + b )( list );7 list.reduce!( min, max )( );

.

. .. 96/122.. . . . . . . . . . . . . . . . . . . .. 96/122.

D Programming .

.

.. . . Forward.

.

. ... Back

D Programming

Jonathan MERCIER

IntroductionObject

Functional

Meta-programming

Parallelism

Ressource Management

Contract

System and Safe Code

Reference and pointer

Generics

Inference

Loops

Functions

Debugs

Versions

Requirement

Editors

BasicsMy first D program

Types

Arrays

String and characters

Const and Immutable

Input/Output

Algorithm

Structure and Class

Template

Miscellanous

Let start it!

GTK D

Thanks To

Algorithm

..

Code 26: Iteration1 import std.algorihm: filter, uniq, map, reduce;2 int[] list = [ 0, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9 ];3 list.filter!( a => a > 6 );4 list.uniq( );5 list.map!( a => a + 2 );6 0.reduce!( (a,b) => a + b )( list ); // sum all elements => 49 ..7 list.reduce!( min, max )( );

.

. .. 97/122.. . . . . . . . . . . . . . . . . . . .. 97/122.

D Programming .

.

.. . . Forward.

.

. ... Back

D Programming

Jonathan MERCIER

IntroductionObject

Functional

Meta-programming

Parallelism

Ressource Management

Contract

System and Safe Code

Reference and pointer

Generics

Inference

Loops

Functions

Debugs

Versions

Requirement

Editors

BasicsMy first D program

Types

Arrays

String and characters

Const and Immutable

Input/Output

Algorithm

Structure and Class

Template

Miscellanous

Let start it!

GTK D

Thanks To

Algorithm

..

Code 27: Iteration1 import std.algorihm: filter, uniq, map, reduce;2 int[] list = [ 0, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9 ];3 list.filter!( a => a > 6 );4 list.uniq( );5 list.map!( a => a + 2 );6 0.reduce!( (a,b) => a + b )( list );7 list.reduce!( min, max )( ); // compute in one pass min an max ..8 // min: 0 max: 9

.

. .. 98/122.. . . . . . . . . . . . . . . . . . . .. 98/122.

D Programming .

.

.. . . Forward.

.

. ... Back

D Programming

Jonathan MERCIER

IntroductionObject

Functional

Meta-programming

Parallelism

Ressource Management

Contract

System and Safe Code

Reference and pointer

Generics

Inference

Loops

Functions

Debugs

Versions

Requirement

Editors

BasicsMy first D program

Types

Arrays

String and characters

Const and Immutable

Input/Output

Algorithm

Structure and Class

Template

Miscellanous

Let start it!

GTK D

Thanks To

Algorithm

..

Code 28: Sorting1 import std.stdio;2 import std.algorithm;3 import std.array;45 void main( ){6 immutable int[] a = [4, 6, 1, 2];7 immutable int[] b = cast(immutable) a.dup8 .sort!( (x,y) => x < y )9 .array;

10 writeln( b ); // [ 1, 2, 4, 6 ]11 }

. .. 99/122.. . . . . . . . . . . . . . . . . . . .. 99/122.

D Programming .

.

.. . . Forward.

.

. ... Back

D Programming

Jonathan MERCIER

IntroductionObject

Functional

Meta-programming

Parallelism

Ressource Management

Contract

System and Safe Code

Reference and pointer

Generics

Inference

Loops

Functions

Debugs

Versions

Requirement

Editors

BasicsMy first D program

Types

Arrays

String and characters

Const and Immutable

Input/Output

Algorithm

Structure and Class

Template

Miscellanous

Let start it!

GTK D

Thanks To

Plan.....1 Introduction

ObjectFunctionalMeta-programmingParallelismRessource ManagementContractSystem and Safe CodeReference and pointerGenericsInferenceLoopsFunctionsDebugsVersionsRequirementEditors

...2 BasicsMy first D programTypesArraysString and charactersConst and ImmutableInput/OutputAlgorithmStructure and ClassTemplateMiscellanousLet start it!

...3 GTK D

...4 Thanks To. .. 100/122.. . . . . . . . . . . . . . . . . . . .. 100/122.

D Programming .

.

.. . . Forward.

.

. ... Back

D Programming

Jonathan MERCIER

IntroductionObject

Functional

Meta-programming

Parallelism

Ressource Management

Contract

System and Safe Code

Reference and pointer

Generics

Inference

Loops

Functions

Debugs

Versions

Requirement

Editors

BasicsMy first D program

Types

Arrays

String and characters

Const and Immutable

Input/Output

Algorithm

Structure and Class

Template

Miscellanous

Let start it!

GTK D

Thanks To

Structure

..

Code 29: Classic implementation1 struct MyStruct{2 int field1;3 float fiel2;4 string field3;5 }

. .. 101/122.. . . . . . . . . . . . . . . . . . . . .. 101/122.

D Programming .

.

.. . . Forward.

.

. ... Back

D Programming

Jonathan MERCIER

IntroductionObject

Functional

Meta-programming

Parallelism

Ressource Management

Contract

System and Safe Code

Reference and pointer

Generics

Inference

Loops

Functions

Debugs

Versions

Requirement

Editors

BasicsMy first D program

Types

Arrays

String and characters

Const and Immutable

Input/Output

Algorithm

Structure and Class

Template

Miscellanous

Let start it!

GTK D

Thanks To

Structure

..

Code 30: With constructor and modifier1 struct MyStruct{2 private:3 int _field1;4 float _fiel2;5 string _field3;67 public:8 this( int f1, float f2, string f3 ){9 _field1 = f1;

10 _field2 = f2;11 _field3 = f3;12 }13 }

. .. 102/122.. . . . . . . . . . . . . . . . . . . . .. 102/122.

D Programming .

.

.. . . Forward.

.

. ... Back

D Programming

Jonathan MERCIER

IntroductionObject

Functional

Meta-programming

Parallelism

Ressource Management

Contract

System and Safe Code

Reference and pointer

Generics

Inference

Loops

Functions

Debugs

Versions

Requirement

Editors

BasicsMy first D program

Types

Arrays

String and characters

Const and Immutable

Input/Output

Algorithm

Structure and Class

Template

Miscellanous

Let start it!

GTK D

Thanks To

Structure

..

Code 31: With method and property1 struct MyStruct{2 private:3 int _field1;4 float _field2;5 string _field3;6 public:7 this( int f1, float f2, string f3 ){8 _field1 = f1;9 _field2 = f2;

10 _field3 = f3;11 }12 this( MyStruct s ){13 _field1 = s.field1;14 _field2 = s.field2;15 _field3 = s.field3;16 }17 @property int field1( ) const { return _field1; }18 @property void field1( int f1 ){ _field1 = f1; }19 @property float field2( ) const { return _field2; }20 @property void field2( float f2 ){ _field2 = f2; }21 @property string field3( ) const { return _field3; }22 @property void field3( string f3 ){ _field3 = f3; }23 MyStruct dup() const{ return MyStruct( this ); }24 }

. .. 103/122.. . . . . . . . . . . . . . . . . . . . .. 103/122.

D Programming .

.

.. . . Forward.

.

. ... Back

D Programming

Jonathan MERCIER

IntroductionObject

Functional

Meta-programming

Parallelism

Ressource Management

Contract

System and Safe Code

Reference and pointer

Generics

Inference

Loops

Functions

Debugs

Versions

Requirement

Editors

BasicsMy first D program

Types

Arrays

String and characters

Const and Immutable

Input/Output

Algorithm

Structure and Class

Template

Miscellanous

Let start it!

GTK D

Thanks To

Class

..

Code 32: Polymorphism1 import std.string: format;23 Interface IPersonnage{4 string name();5 int health();6 int mana();7 }89 class BowMan: IPersonnage{

10 private:11 string _name;12 int _health;13 int _mana;14 public:15 this( string n, int h, int m ){16 _name = n;17 _health = h;18 _mana = m;19 }20 string name() const { return _name; }21 int health() const { return _health; }22 int mana() const { return _mana; }23 override string toString() const{24 return ”name: %s point: %d mana: %d”.format(_name, _health,

_mana);25 }26 }

. .. 104/122.. . . . . . . . . . . . . . . . . . . . .. 104/122.

D Programming .

.

.. . . Forward.

.

. ... Back

D Programming

Jonathan MERCIER

IntroductionObject

Functional

Meta-programming

Parallelism

Ressource Management

Contract

System and Safe Code

Reference and pointer

Generics

Inference

Loops

Functions

Debugs

Versions

Requirement

Editors

BasicsMy first D program

Types

Arrays

String and characters

Const and Immutable

Input/Output

Algorithm

Structure and Class

Template

Miscellanous

Let start it!

GTK D

Thanks To

Plan.....1 Introduction

ObjectFunctionalMeta-programmingParallelismRessource ManagementContractSystem and Safe CodeReference and pointerGenericsInferenceLoopsFunctionsDebugsVersionsRequirementEditors

...2 BasicsMy first D programTypesArraysString and charactersConst and ImmutableInput/OutputAlgorithmStructure and ClassTemplateMiscellanousLet start it!

...3 GTK D

...4 Thanks To. .. 105/122.. . . . . . . . . . . . . . . . . . . . .. 105/122.

D Programming .

.

.. . . Forward.

.

. ... Back

D Programming

Jonathan MERCIER

IntroductionObject

Functional

Meta-programming

Parallelism

Ressource Management

Contract

System and Safe Code

Reference and pointer

Generics

Inference

Loops

Functions

Debugs

Versions

Requirement

Editors

BasicsMy first D program

Types

Arrays

String and characters

Const and Immutable

Input/Output

Algorithm

Structure and Class

Template

Miscellanous

Let start it!

GTK D

Thanks To

Template

..

Code 33: Function template1 auto addition(T,U)( T a, U b){2 return a + b;3 }

. .. 106/122.. . . . . . . . . . . . . . . . . . . . . .. 106/122.

D Programming .

.

.. . . Forward.

.

. ... Back

D Programming

Jonathan MERCIER

IntroductionObject

Functional

Meta-programming

Parallelism

Ressource Management

Contract

System and Safe Code

Reference and pointer

Generics

Inference

Loops

Functions

Debugs

Versions

Requirement

Editors

BasicsMy first D program

Types

Arrays

String and characters

Const and Immutable

Input/Output

Algorithm

Structure and Class

Template

Miscellanous

Let start it!

GTK D

Thanks To

Template

..

Code 34: Struct template1 struct TStruct(T) {2 private:3 T _f1;4 public:5 this ( T f1 ){6 _f1 = f1;7 }8 }9 void main(){

10 TStruct!string t1 = TStruct!(string)( ”test” );11 auto t2 = TStruct!int( 5 );12 }

. .. 107/122.. . . . . . . . . . . . . . . . . . . . . .. 107/122.

D Programming .

.

.. . . Forward.

.

. ... Back

D Programming

Jonathan MERCIER

IntroductionObject

Functional

Meta-programming

Parallelism

Ressource Management

Contract

System and Safe Code

Reference and pointer

Generics

Inference

Loops

Functions

Debugs

Versions

Requirement

Editors

BasicsMy first D program

Types

Arrays

String and characters

Const and Immutable

Input/Output

Algorithm

Structure and Class

Template

Miscellanous

Let start it!

GTK D

Thanks To

Template

..

Code 35: Class template1 class TClass(T) {2 private:3 T _f1;4 public:5 this ( T f1 ){6 _f1 = f1;7 }8 }9 auto c1 = new TClass!int( 2 );

. .. 108/122.. . . . . . . . . . . . . . . . . . . . . .. 108/122.

D Programming .

.

.. . . Forward.

.

. ... Back

D Programming

Jonathan MERCIER

IntroductionObject

Functional

Meta-programming

Parallelism

Ressource Management

Contract

System and Safe Code

Reference and pointer

Generics

Inference

Loops

Functions

Debugs

Versions

Requirement

Editors

BasicsMy first D program

Types

Arrays

String and characters

Const and Immutable

Input/Output

Algorithm

Structure and Class

Template

Miscellanous

Let start it!

GTK D

Thanks To

Plan.....1 Introduction

ObjectFunctionalMeta-programmingParallelismRessource ManagementContractSystem and Safe CodeReference and pointerGenericsInferenceLoopsFunctionsDebugsVersionsRequirementEditors

...2 BasicsMy first D programTypesArraysString and charactersConst and ImmutableInput/OutputAlgorithmStructure and ClassTemplateMiscellanousLet start it!

...3 GTK D

...4 Thanks To. .. 109/122.. . . . . . . . . . . . . . . . . . . . . .. 109/122.

D Programming .

.

.. . . Forward.

.

. ... Back

D Programming

Jonathan MERCIER

IntroductionObject

Functional

Meta-programming

Parallelism

Ressource Management

Contract

System and Safe Code

Reference and pointer

Generics

Inference

Loops

Functions

Debugs

Versions

Requirement

Editors

BasicsMy first D program

Types

Arrays

String and characters

Const and Immutable

Input/Output

Algorithm

Structure and Class

Template

Miscellanous

Let start it!

GTK D

Thanks To

Miscellanous

..1 int β= 5; // variable name can use UTF−8 char2 int i = 1_000_000; // easy to read number

. .. 110/122.. . . . . . . . . . . . . . . . . . . . . .. 110/122.

D Programming .

.

.. . . Forward.

.

. ... Back

D Programming

Jonathan MERCIER

IntroductionObject

Functional

Meta-programming

Parallelism

Ressource Management

Contract

System and Safe Code

Reference and pointer

Generics

Inference

Loops

Functions

Debugs

Versions

Requirement

Editors

BasicsMy first D program

Types

Arrays

String and characters

Const and Immutable

Input/Output

Algorithm

Structure and Class

Template

Miscellanous

Let start it!

GTK D

Thanks To

Plan.....1 Introduction

ObjectFunctionalMeta-programmingParallelismRessource ManagementContractSystem and Safe CodeReference and pointerGenericsInferenceLoopsFunctionsDebugsVersionsRequirementEditors

...2 BasicsMy first D programTypesArraysString and charactersConst and ImmutableInput/OutputAlgorithmStructure and ClassTemplateMiscellanousLet start it!

...3 GTK D

...4 Thanks To. .. 111/122.. . . . . . . . . . . . . . . . . . . . . . .. 111/122.

D Programming .

.

.. . . Forward.

.

. ... Back

D Programming

Jonathan MERCIER

IntroductionObject

Functional

Meta-programming

Parallelism

Ressource Management

Contract

System and Safe Code

Reference and pointer

Generics

Inference

Loops

Functions

Debugs

Versions

Requirement

Editors

BasicsMy first D program

Types

Arrays

String and characters

Const and Immutable

Input/Output

Algorithm

Structure and Class

Template

Miscellanous

Let start it!

GTK D

Thanks To

What Are You Waiting For?

.

......

Web site: dlang.org

Community: forum.dlang.orgContribute:www.github.com/D-Programming-Languageirc on freenode #dfrench speaker on jabber d-fr@chat.jabberfr.org

. .. 112/122.. . . . . . . . . . . . . . . . . . . . . . .. 112/122.

D Programming .

.

.. . . Forward.

.

. ... Back

D Programming

Jonathan MERCIER

IntroductionObject

Functional

Meta-programming

Parallelism

Ressource Management

Contract

System and Safe Code

Reference and pointer

Generics

Inference

Loops

Functions

Debugs

Versions

Requirement

Editors

BasicsMy first D program

Types

Arrays

String and characters

Const and Immutable

Input/Output

Algorithm

Structure and Class

Template

Miscellanous

Let start it!

GTK D

Thanks To

What Are You Waiting For?

.

......

Web site: dlang.orgCommunity: forum.dlang.org

Contribute:www.github.com/D-Programming-Languageirc on freenode #dfrench speaker on jabber d-fr@chat.jabberfr.org

. .. 112/122.. . . . . . . . . . . . . . . . . . . . . . .. 112/122.

D Programming .

.

.. . . Forward.

.

. ... Back

D Programming

Jonathan MERCIER

IntroductionObject

Functional

Meta-programming

Parallelism

Ressource Management

Contract

System and Safe Code

Reference and pointer

Generics

Inference

Loops

Functions

Debugs

Versions

Requirement

Editors

BasicsMy first D program

Types

Arrays

String and characters

Const and Immutable

Input/Output

Algorithm

Structure and Class

Template

Miscellanous

Let start it!

GTK D

Thanks To

What Are You Waiting For?

.

......

Web site: dlang.orgCommunity: forum.dlang.orgContribute:www.github.com/D-Programming-Language

irc on freenode #dfrench speaker on jabber d-fr@chat.jabberfr.org

. .. 112/122.. . . . . . . . . . . . . . . . . . . . . . .. 112/122.

D Programming .

.

.. . . Forward.

.

. ... Back

D Programming

Jonathan MERCIER

IntroductionObject

Functional

Meta-programming

Parallelism

Ressource Management

Contract

System and Safe Code

Reference and pointer

Generics

Inference

Loops

Functions

Debugs

Versions

Requirement

Editors

BasicsMy first D program

Types

Arrays

String and characters

Const and Immutable

Input/Output

Algorithm

Structure and Class

Template

Miscellanous

Let start it!

GTK D

Thanks To

What Are You Waiting For?

.

......

Web site: dlang.orgCommunity: forum.dlang.orgContribute:www.github.com/D-Programming-Languageirc on freenode #d

french speaker on jabber d-fr@chat.jabberfr.org

. .. 112/122.. . . . . . . . . . . . . . . . . . . . . . .. 112/122.

D Programming .

.

.. . . Forward.

.

. ... Back

D Programming

Jonathan MERCIER

IntroductionObject

Functional

Meta-programming

Parallelism

Ressource Management

Contract

System and Safe Code

Reference and pointer

Generics

Inference

Loops

Functions

Debugs

Versions

Requirement

Editors

BasicsMy first D program

Types

Arrays

String and characters

Const and Immutable

Input/Output

Algorithm

Structure and Class

Template

Miscellanous

Let start it!

GTK D

Thanks To

What Are You Waiting For?

.

......

Web site: dlang.orgCommunity: forum.dlang.orgContribute:www.github.com/D-Programming-Languageirc on freenode #dfrench speaker on jabber d-fr@chat.jabberfr.org

. .. 112/122.. . . . . . . . . . . . . . . . . . . . . . .. 112/122.

D Programming .

.

.. . . Forward.

.

. ... Back

D Programming

Jonathan MERCIER

IntroductionObject

Functional

Meta-programming

Parallelism

Ressource Management

Contract

System and Safe Code

Reference and pointer

Generics

Inference

Loops

Functions

Debugs

Versions

Requirement

Editors

BasicsMy first D program

Types

Arrays

String and characters

Const and Immutable

Input/Output

Algorithm

Structure and Class

Template

Miscellanous

Let start it!

GTK D

Thanks To

GTK D

..

Code 36: First graphical application1 module myFirstGUI;23 import gtk.MainWindow;4 import gtk.Label;5 import gtk.Main;67 class myFirstGUI: MainWindow{8 this(){9 super(”GtkD”);

10 setBorderWidth(10);11 add(new Label(”Hello World”));12 showAll();13 }14 }1516 void main(string[] args){17 Main.init(args);18 new HelloWorld();19 Main.run();2021 }

. .. 113/122.. . . . . . . . . . . . . . . . . . . . . . .. 113/122.

D Programming .

.

.. . . Forward.

.

. ... Back

D Programming

Jonathan MERCIER

IntroductionObject

Functional

Meta-programming

Parallelism

Ressource Management

Contract

System and Safe Code

Reference and pointer

Generics

Inference

Loops

Functions

Debugs

Versions

Requirement

Editors

BasicsMy first D program

Types

Arrays

String and characters

Const and Immutable

Input/Output

Algorithm

Structure and Class

Template

Miscellanous

Let start it!

GTK D

Thanks To

GTK D

..

Code 37: Terminal$ ldc2 -L-lgtkd -L-ldl myFirstGUI.d$ ./myFistGUI

. .. 114/122.. . . . . . . . . . . . . . . . . . . . . . .. 114/122.

D Programming .

.

.. . . Forward.

.

. ... Back

D Programming

Jonathan MERCIER

IntroductionObject

Functional

Meta-programming

Parallelism

Ressource Management

Contract

System and Safe Code

Reference and pointer

Generics

Inference

Loops

Functions

Debugs

Versions

Requirement

Editors

BasicsMy first D program

Types

Arrays

String and characters

Const and Immutable

Input/Output

Algorithm

Structure and Class

Template

Miscellanous

Let start it!

GTK D

Thanks To

GTK D

..

Code 38: First graphical application1 module myFirstGUI;23 import gtk.MainWindow;4 import gtk.Label;5 import gtk.Main;67 pragma(lib, ”gtkd”); ..89 class myFirstGUI: MainWindow{

10 this(){11 super(”GtkD”);12 setBorderWidth(10);13 add(new Label(”Hello World”));14 showAll();15 }16 }1718 void main(string[] args){19 Main.init(args);20 new myFirstGUI();21 Main.run();2223 }

.. .. 115/122.. . . . . . . . . . . . . . . . . . . . . . .. 115/122.

D Programming .

.

.. . . Forward.

.

. ... Back

D Programming

Jonathan MERCIER

IntroductionObject

Functional

Meta-programming

Parallelism

Ressource Management

Contract

System and Safe Code

Reference and pointer

Generics

Inference

Loops

Functions

Debugs

Versions

Requirement

Editors

BasicsMy first D program

Types

Arrays

String and characters

Const and Immutable

Input/Output

Algorithm

Structure and Class

Template

Miscellanous

Let start it!

GTK D

Thanks To

GTK D

..

Code 39: First graphical application1 module myFirstGUI;23 import gtk.MainWindow;4 import gtk.Label;5 import gtk.Main;67 pragma(lib, ”gtkd”);89 class myFirstGUI: MainWindow{ ..

10 this(){11 super(”GtkD”);12 setBorderWidth(10);13 add(new Label(”Hello World”));14 showAll();15 }16 }1718 void main(string[] args){19 Main.init(args);20 new myFirstGUI();21 Main.run();2223 }

.. .. 116/122.. . . . . . . . . . . . . . . . . . . . . . . .. 116/122.

D Programming .

.

.. . . Forward.

.

. ... Back

D Programming

Jonathan MERCIER

IntroductionObject

Functional

Meta-programming

Parallelism

Ressource Management

Contract

System and Safe Code

Reference and pointer

Generics

Inference

Loops

Functions

Debugs

Versions

Requirement

Editors

BasicsMy first D program

Types

Arrays

String and characters

Const and Immutable

Input/Output

Algorithm

Structure and Class

Template

Miscellanous

Let start it!

GTK D

Thanks To

GTK D

..

Code 40: First graphical application1 module myFirstGUI;23 import gtk.MainWindow;4 import gtk.Label;5 import gtk.Main;67 pragma(lib, ”gtkd”);89 class myFirstGUI: MainWindow{

10 this(){11 super(”GtkD”);12 setBorderWidth(10);13 add(new Label(”Hello World”));14 showAll();15 }16 }1718 void main(string[] args){ ..19 Main.init(args);20 new myFirstGUI();21 Main.run();2223 }

.. .. 117/122.. . . . . . . . . . . . . . . . . . . . . . . .. 117/122.

D Programming .

.

.. . . Forward.

.

. ... Back

D Programming

Jonathan MERCIER

IntroductionObject

Functional

Meta-programming

Parallelism

Ressource Management

Contract

System and Safe Code

Reference and pointer

Generics

Inference

Loops

Functions

Debugs

Versions

Requirement

Editors

BasicsMy first D program

Types

Arrays

String and characters

Const and Immutable

Input/Output

Algorithm

Structure and Class

Template

Miscellanous

Let start it!

GTK D

Thanks To

First graphical Application

..

Code 41: Terminal$ ldc2 -L-ldl myFirstGUI.d$ ./myFistGUI

. .. 118/122.. . . . . . . . . . . . . . . . . . . . . . . .. 118/122.

D Programming .

.

.. . . Forward.

.

. ... Back

D Programming

Jonathan MERCIER

IntroductionObject

Functional

Meta-programming

Parallelism

Ressource Management

Contract

System and Safe Code

Reference and pointer

Generics

Inference

Loops

Functions

Debugs

Versions

Requirement

Editors

BasicsMy first D program

Types

Arrays

String and characters

Const and Immutable

Input/Output

Algorithm

Structure and Class

Template

Miscellanous

Let start it!

GTK D

Thanks To

GTK D

..

Code 42: First graphical application1 module myFirstGUI;23 import gtk.MainWindow;4 import gtk.Label;5 import gtk.Main;67 pragma(lib, ”gtkd”);8 version( Linux ) pragma(lib, ”dl”); ..9

10 class myFirstGUI: MainWindow{11 this(){12 super(”GtkD”);13 setBorderWidth(10);14 add(new Label(”Hello World”));15 showAll();16 }17 }1819 void main(string[] args){20 Main.init(args);21 new myFirstGUI();22 Main.run();2324 }

.. .. 119/122.. . . . . . . . . . . . . . . . . . . . . . . .. 119/122.

D Programming .

.

.. . . Forward.

.

. ... Back

D Programming

Jonathan MERCIER

IntroductionObject

Functional

Meta-programming

Parallelism

Ressource Management

Contract

System and Safe Code

Reference and pointer

Generics

Inference

Loops

Functions

Debugs

Versions

Requirement

Editors

BasicsMy first D program

Types

Arrays

String and characters

Const and Immutable

Input/Output

Algorithm

Structure and Class

Template

Miscellanous

Let start it!

GTK D

Thanks To

First graphical Application

..

Code 43: Terminal$ ldc2 myFirstGUI.d$ ./myFistGUI

. .. 120/122.. . . . . . . . . . . . . . . . . . . . . . . .. 120/122.

D Programming .

.

.. . . Forward.

.

. ... Back

D Programming

Jonathan MERCIER

IntroductionObject

Functional

Meta-programming

Parallelism

Ressource Management

Contract

System and Safe Code

Reference and pointer

Generics

Inference

Loops

Functions

Debugs

Versions

Requirement

Editors

BasicsMy first D program

Types

Arrays

String and characters

Const and Immutable

Input/Output

Algorithm

Structure and Class

Template

Miscellanous

Let start it!

GTK D

Thanks To

Contact

.Comments, suggestions or bug reports ?..

......Please send a mail at:bioinfornatics@fedoraproject.org

. .. 121/122.. . . . . . . . . . . . . . . . . . . . . . . . .. 121/122.

D Programming .

.

.. . . Forward.

.

. ... Back

D Programming

Jonathan MERCIER

IntroductionObject

Functional

Meta-programming

Parallelism

Ressource Management

Contract

System and Safe Code

Reference and pointer

Generics

Inference

Loops

Functions

Debugs

Versions

Requirement

Editors

BasicsMy first D program

Types

Arrays

String and characters

Const and Immutable

Input/Output

Algorithm

Structure and Class

Template

Miscellanous

Let start it!

GTK D

Thanks To

Thanks to.

......

To your attentionFrench fedora communityD communityMohamed El Morabity

. .. 122/122.. . . . . . . . . . . . . . . . . . . . . . . . .. 122/122.

D Programming .

.

. ... Back