Fudcon D programming

731 views

Published on

Published in: Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
731
On SlideShare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
19
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Fudcon D programming

  1. 1. D Programming .Jonathan MERCIERIntroduction D ProgrammingObject . In nutshellFunctionalMeta-programmingParallelismRessource ManagementContract Jonathan MERCIERSystem and Safe CodeReference and pointerGenericsInferenceLoopsFunctions December 9, 2012DebugsVersionsRequirementEditorsBasicsMy first D programTypesArraysString and charactersConst and ImmutableInput/OutputAlgorithmStructure and ClassTemplateMiscellanous . . 1/122 .Let start it! D Programming . . . . Forward .GTK D
  2. 2. D ProgrammingJonathan MERCIER Plan .. 1 IntroductionIntroduction ObjectObject FunctionalFunctional Meta-programmingMeta-programming ParallelismParallelism Ressource ManagementRessource Management Contract System and Safe CodeContract Reference and pointerSystem and Safe Code GenericsReference and pointer InferenceGenerics LoopsInference FunctionsLoops DebugsFunctions VersionsDebugs RequirementVersions EditorsRequirement . 2 BasicsEditors My first D program TypesBasics ArraysMy first D program String and charactersTypes Const and ImmutableArrays Input/OutputString and characters AlgorithmConst and Immutable Structure and ClassInput/Output TemplateAlgorithm MiscellanousStructure and Class Let start it! . 3 GTK DTemplate . 4 Thanks ToMiscellanous . . . . 2/122 .Let start it! D Programming . . . . Back . . . . . Forward .GTK D
  3. 3. D ProgrammingJonathan MERCIER Before startingIntroductionObjectFunctionalMeta-programmingParallelismRessource ManagementContractSystem and Safe CodeReference and pointerGenericsInferenceLoopsFunctionsDebugsVersionsRequirementEditorsBasicsMy first D programTypesArraysString and charactersConst and ImmutableInput/OutputAlgorithmStructure and ClassTemplateMiscellanous . . . . 3/122 .Let start it! D Programming . . . . Back . . . . . Forward .GTK D
  4. 4. D ProgrammingJonathan MERCIER Why a new language?IntroductionObjectFunctionalMeta-programmingParallelismRessource Management .Contract Few significant datesSystem and Safe Code .Reference and pointer C++ 1983GenericsInferenceLoopsFunctionsDebugsVersionsRequirementEditorsBasicsMy first D program .TypesArraysString and charactersConst and ImmutableInput/OutputAlgorithmStructure and ClassTemplateMiscellanous . . . . 4/122 .Let start it! D Programming . . . . Back . . . . . Forward .GTK D
  5. 5. D ProgrammingJonathan MERCIER Why a new language?IntroductionObjectFunctionalMeta-programmingParallelismRessource Management .Contract Few significant datesSystem and Safe Code .Reference and pointer C++ 1983GenericsInferenceLoops Java 1990FunctionsDebugsVersionsRequirementEditorsBasicsMy first D program .TypesArraysString and charactersConst and ImmutableInput/OutputAlgorithmStructure and ClassTemplateMiscellanous . . . . 4/122 .Let start it! D Programming . . . . Back . . . . . Forward .GTK D
  6. 6. D ProgrammingJonathan MERCIER Why a new language?IntroductionObjectFunctionalMeta-programmingParallelismRessource Management .Contract Few significant datesSystem and Safe Code .Reference and pointer C++ 1983GenericsInferenceLoops Java 1990FunctionsDebugs Python 1995VersionsRequirementEditorsBasicsMy first D program .TypesArraysString and charactersConst and ImmutableInput/OutputAlgorithmStructure and ClassTemplateMiscellanous . . . . 4/122 .Let start it! D Programming . . . . Back . . . . . Forward .GTK D
  7. 7. D ProgrammingJonathan MERCIER Why a new language?IntroductionObjectFunctionalMeta-programmingParallelismRessource Management .Contract Few significant datesSystem and Safe Code .Reference and pointer C++ 1983GenericsInferenceLoops Java 1990FunctionsDebugs Python 1995VersionsRequirement Ruby 1995EditorsBasicsMy first D program .TypesArraysString and charactersConst and ImmutableInput/OutputAlgorithmStructure and ClassTemplateMiscellanous . . . . 4/122 .Let start it! D Programming . . . . Back . . . . . Forward .GTK D
  8. 8. D ProgrammingJonathan MERCIER Why a new language?IntroductionObjectFunctionalMeta-programmingParallelismRessource Management .Contract Few significant datesSystem and Safe Code .Reference and pointer C++ 1983GenericsInferenceLoops Java 1990FunctionsDebugs Python 1995VersionsRequirement Ruby 1995 And now?EditorsBasicsMy first D program .TypesArraysString and charactersConst and ImmutableInput/OutputAlgorithmStructure and ClassTemplateMiscellanous . . . . 4/122 .Let start it! D Programming . . . . Back . . . . . Forward .GTK D
  9. 9. D ProgrammingJonathan MERCIER What is D programming?IntroductionObjectFunctionalMeta-programmingParallelismRessource ManagementContractSystem and Safe Code D is a modern language programming inspired by:Reference and pointerGenerics C++InferenceLoops JavaFunctionsDebugs HaskellVersionsRequirement PythonEditorsBasics RubyMy first D programTypesArraysString and charactersConst and ImmutableInput/OutputAlgorithmStructure and ClassTemplateMiscellanous . . . . 5/122 .Let start it! D Programming . . . . Back . . . . . Forward .GTK D
  10. 10. D ProgrammingJonathan MERCIER Why a new language?IntroductionObjectFunctionalMeta-programmingParallelismRessource ManagementContractSystem and Safe Code .Reference and pointer D CombinesGenerics .Inference Modeling PowerLoopsFunctionsDebugsVersions .RequirementEditorsBasicsMy first D programTypesArraysString and charactersConst and ImmutableInput/OutputAlgorithmStructure and ClassTemplateMiscellanous . . . . . 6/122 .Let start it! D Programming . . . . Back . . . . . Forward .GTK D
  11. 11. D ProgrammingJonathan MERCIER Why a new language?IntroductionObjectFunctionalMeta-programmingParallelismRessource ManagementContractSystem and Safe Code .Reference and pointer D CombinesGenerics .Inference Modeling PowerLoopsFunctionsDebugs Modern ConvenienceVersions .RequirementEditorsBasicsMy first D programTypesArraysString and charactersConst and ImmutableInput/OutputAlgorithmStructure and ClassTemplateMiscellanous . . . . . 6/122 .Let start it! D Programming . . . . Back . . . . . Forward .GTK D
  12. 12. D ProgrammingJonathan MERCIER Why a new language?IntroductionObjectFunctionalMeta-programmingParallelismRessource ManagementContractSystem and Safe Code .Reference and pointer D CombinesGenerics .Inference Modeling PowerLoopsFunctionsDebugs Modern ConvenienceVersions Native Efficiency .RequirementEditorsBasicsMy first D programTypesArraysString and charactersConst and ImmutableInput/OutputAlgorithmStructure and ClassTemplateMiscellanous . . . . . 6/122 .Let start it! D Programming . . . . Back . . . . . Forward .GTK D
  13. 13. D ProgrammingJonathan MERCIER Plan .. 1 IntroductionIntroduction ObjectObject FunctionalFunctional Meta-programmingMeta-programming ParallelismParallelism Ressource ManagementRessource Management Contract System and Safe CodeContract Reference and pointerSystem and Safe Code GenericsReference and pointer InferenceGenerics LoopsInference FunctionsLoops DebugsFunctions VersionsDebugs RequirementVersions EditorsRequirement . 2 BasicsEditors My first D program TypesBasics ArraysMy first D program String and charactersTypes Const and ImmutableArrays Input/OutputString and characters AlgorithmConst and Immutable Structure and ClassInput/Output TemplateAlgorithm MiscellanousStructure and Class Let start it! . 3 GTK DTemplate . 4 Thanks ToMiscellanous . . . . . 7/122 .Let start it! D Programming . . . . Back . . . . . Forward .GTK D
  14. 14. D ProgrammingJonathan MERCIER ObjectIntroductionObjectFunctionalMeta-programming .ParallelismRessource Management InterfaceContract 1 interface foo { …}System and Safe Code .Reference and pointerGenericsInferenceLoopsFunctionsDebugsVersionsRequirementEditorsBasicsMy first D programTypesArraysString and characters .Const and ImmutableInput/OutputAlgorithmStructure and ClassTemplateMiscellanous . . . . . 8/122 .Let start it! D Programming . . . . Back . . . . . Forward .GTK D
  15. 15. D ProgrammingJonathan MERCIER ObjectIntroductionObjectFunctionalMeta-programming .ParallelismRessource Management InterfaceContract 1 interface foo { …}System and Safe Code .Reference and pointerGenerics classInferenceLoops 1 class bar { …}Functions .DebugsVersionsRequirementEditorsBasicsMy first D programTypesArraysString and characters .Const and ImmutableInput/OutputAlgorithmStructure and ClassTemplateMiscellanous . . . . . 8/122 .Let start it! D Programming . . . . Back . . . . . Forward .GTK D
  16. 16. D ProgrammingJonathan MERCIER ObjectIntroductionObjectFunctionalMeta-programming .ParallelismRessource Management InterfaceContract 1 interface foo { …}System and Safe Code .Reference and pointerGenerics classInferenceLoops 1 class bar { …}Functions .DebugsVersions inheritanceRequirement 1 class bar: foo { …}Editors .BasicsMy first D programTypesArraysString and characters .Const and ImmutableInput/OutputAlgorithmStructure and ClassTemplateMiscellanous . . . . . 8/122 .Let start it! D Programming . . . . Back . . . . . Forward .GTK D
  17. 17. D ProgrammingJonathan MERCIER ObjectIntroductionObjectFunctionalMeta-programming .ParallelismRessource Management InterfaceContract 1 interface foo { …}System and Safe Code .Reference and pointerGenerics classInferenceLoops 1 class bar { …}Functions .DebugsVersions inheritanceRequirement 1 class bar: foo { …}Editors .BasicsMy first D program multi class inheritance not allowed, instead usedTypesArrays interface.String and characters .Const and ImmutableInput/OutputAlgorithmStructure and ClassTemplateMiscellanous . . . . . 8/122 .Let start it! D Programming . . . . Back . . . . . Forward .GTK D
  18. 18. D ProgrammingJonathan MERCIER Plan .. 1 IntroductionIntroduction ObjectObject FunctionalFunctional Meta-programmingMeta-programming ParallelismParallelism Ressource ManagementRessource Management Contract System and Safe CodeContract Reference and pointerSystem and Safe Code GenericsReference and pointer InferenceGenerics LoopsInference FunctionsLoops DebugsFunctions VersionsDebugs RequirementVersions EditorsRequirement . 2 BasicsEditors My first D program TypesBasics ArraysMy first D program String and charactersTypes Const and ImmutableArrays Input/OutputString and characters AlgorithmConst and Immutable Structure and ClassInput/Output TemplateAlgorithm MiscellanousStructure and Class Let start it! . 3 GTK DTemplate . 4 Thanks ToMiscellanous . . . . . 9/122 .Let start it! D Programming . . . . Back . . . . . Forward .GTK D
  19. 19. D ProgrammingJonathan MERCIER FunctionalIntroductionObjectFunctionalMeta-programmingParallelismRessource Management .Contract Data immutabilitySystem and Safe CodeReference and pointer 1 immutable int[] a = [ 4, 6, 1, 2];Generics .InferenceLoopsFunctionsDebugsVersionsRequirementEditorsBasicsMy first D programTypes .ArraysString and charactersConst and ImmutableInput/OutputAlgorithmStructure and ClassTemplateMiscellanous . . . . . 10/122 .Let start it! D Programming . . . . Back . . . . . Forward .GTK D
  20. 20. D ProgrammingJonathan MERCIER FunctionalIntroductionObjectFunctionalMeta-programmingParallelismRessource Management .Contract Data immutabilitySystem and Safe CodeReference and pointer 1 immutable int[] a = [ 4, 6, 1, 2];Generics .InferenceLoops Pure functionsFunctions 1 pure int square(int x) { return x * x; }DebugsVersions .RequirementEditorsBasicsMy first D programTypes .ArraysString and charactersConst and ImmutableInput/OutputAlgorithmStructure and ClassTemplateMiscellanous . . . . . 10/122 .Let start it! D Programming . . . . Back . . . . . Forward .GTK D
  21. 21. D ProgrammingJonathan MERCIER FunctionalIntroductionObjectFunctionalMeta-programmingParallelismRessource Management .Contract Data immutabilitySystem and Safe CodeReference and pointer 1 immutable int[] a = [ 4, 6, 1, 2];Generics .InferenceLoops Pure functionsFunctions 1 pure int square(int x) { return x * x; }DebugsVersions .RequirementEditors Lambda functions 1 a.sort!( (x,y) => x < y ); // [ 1, 2, 4, 6 ]Basics .My first D programTypes .ArraysString and charactersConst and ImmutableInput/OutputAlgorithmStructure and ClassTemplateMiscellanous . . . . . 10/122 .Let start it! D Programming . . . . Back . . . . . Forward .GTK D
  22. 22. D ProgrammingJonathan MERCIER Plan .. 1 IntroductionIntroduction ObjectObject FunctionalFunctional Meta-programmingMeta-programming ParallelismParallelism Ressource ManagementRessource Management Contract System and Safe CodeContract Reference and pointerSystem and Safe Code GenericsReference and pointer InferenceGenerics LoopsInference FunctionsLoops DebugsFunctions VersionsDebugs RequirementVersions EditorsRequirement . 2 BasicsEditors My first D program TypesBasics ArraysMy first D program String and charactersTypes Const and ImmutableArrays Input/OutputString and characters AlgorithmConst and Immutable Structure and ClassInput/Output TemplateAlgorithm MiscellanousStructure and Class Let start it! . 3 GTK DTemplate . 4 Thanks ToMiscellanous . . . . . . 11/122 .Let start it! D Programming . . . . Back . . . . . Forward .GTK D
  23. 23. D ProgrammingJonathan MERCIER Meta-programmingIntroductionObjectFunctionalMeta-programmingParallelismRessource ManagementContract .System and Safe Code Combination ofReference and pointer .Generics templatesInferenceLoopsFunctionsDebugsVersionsRequirementEditorsBasics .My first D programTypesArraysString and charactersConst and ImmutableInput/OutputAlgorithmStructure and ClassTemplateMiscellanous . . . . . . 12/122 .Let start it! D Programming . . . . Back . . . . . Forward .GTK D
  24. 24. D ProgrammingJonathan MERCIER Meta-programmingIntroductionObjectFunctionalMeta-programmingParallelismRessource ManagementContract .System and Safe Code Combination ofReference and pointer .Generics templatesInferenceLoopsFunctions compile time function executionDebugsVersionsRequirementEditorsBasics .My first D programTypesArraysString and charactersConst and ImmutableInput/OutputAlgorithmStructure and ClassTemplateMiscellanous . . . . . . 12/122 .Let start it! D Programming . . . . Back . . . . . Forward .GTK D
  25. 25. D ProgrammingJonathan MERCIER Meta-programmingIntroductionObjectFunctionalMeta-programmingParallelismRessource ManagementContract .System and Safe Code Combination ofReference and pointer .Generics templatesInferenceLoopsFunctions compile time function executionDebugsVersions tuplesRequirementEditorsBasics .My first D programTypesArraysString and charactersConst and ImmutableInput/OutputAlgorithmStructure and ClassTemplateMiscellanous . . . . . . 12/122 .Let start it! D Programming . . . . Back . . . . . Forward .GTK D
  26. 26. D ProgrammingJonathan MERCIER Meta-programmingIntroductionObjectFunctionalMeta-programmingParallelismRessource ManagementContract .System and Safe Code Combination ofReference and pointer .Generics templatesInferenceLoopsFunctions compile time function executionDebugsVersions tuplesRequirementEditors string mixinsBasics .My first D programTypesArraysString and charactersConst and ImmutableInput/OutputAlgorithmStructure and ClassTemplateMiscellanous . . . . . . 12/122 .Let start it! D Programming . . . . Back . . . . . Forward .GTK D
  27. 27. D ProgrammingJonathan MERCIER Meta-programmingIntroductionObjectFunctionalMeta-programmingParallelismRessource ManagementContractSystem and Safe CodeReference and pointer Code 1: ExampleGenerics 1 template Factorial(ulong n){Inference 2 static if(n < 2)Loops 3 const Factorial = 1;Functions 4 elseDebugs 5 const Factorial = n * Factorial!(n − 1);Versions 6 }Requirement 7 const ulong var = Factorial!( 8 ); // compute at compile−timeEditors .BasicsMy first D programTypesArraysString and charactersConst and ImmutableInput/OutputAlgorithmStructure and ClassTemplateMiscellanous . . . . . . 13/122 .Let start it! D Programming . . . . Back . . . . . Forward .GTK D
  28. 28. D ProgrammingJonathan MERCIER Plan .. 1 IntroductionIntroduction ObjectObject FunctionalFunctional Meta-programmingMeta-programming ParallelismParallelism Ressource ManagementRessource Management Contract System and Safe CodeContract Reference and pointerSystem and Safe Code GenericsReference and pointer InferenceGenerics LoopsInference FunctionsLoops DebugsFunctions VersionsDebugs RequirementVersions EditorsRequirement . 2 BasicsEditors My first D program TypesBasics ArraysMy first D program String and charactersTypes Const and ImmutableArrays Input/OutputString and characters AlgorithmConst and Immutable Structure and ClassInput/Output TemplateAlgorithm MiscellanousStructure and Class Let start it! . 3 GTK DTemplate . 4 Thanks ToMiscellanous . . . . . . 14/122 .Let start it! D Programming . . . . Back . . . . . Forward .GTK D
  29. 29. D ProgrammingJonathan MERCIER ParallelismIntroductionObjectFunctionalMeta-programming .ParallelismRessource Management module to useContract 1 import std.parallelism;System and Safe Code .Reference and pointerGenericsInferenceLoopsFunctionsDebugsVersionsRequirementEditorsBasicsMy first D programTypesArraysString and characters .Const and ImmutableInput/OutputAlgorithmStructure and ClassTemplateMiscellanous . . . .. . 15/122 .Let start it! D Programming . . . . Back . . . . . Forward .GTK D
  30. 30. D ProgrammingJonathan MERCIER ParallelismIntroductionObjectFunctionalMeta-programming .ParallelismRessource Management module to useContract 1 import std.parallelism;System and Safe Code .Reference and pointerGenerics parallel loopInferenceLoops 1 foreach( i; parallel( list ) ){ …}Functions .DebugsVersionsRequirementEditorsBasicsMy first D programTypesArraysString and characters .Const and ImmutableInput/OutputAlgorithmStructure and ClassTemplateMiscellanous . . . .. . 15/122 .Let start it! D Programming . . . . Back . . . . . Forward .GTK D
  31. 31. D ProgrammingJonathan MERCIER ParallelismIntroductionObjectFunctionalMeta-programming .ParallelismRessource Management module to useContract 1 import std.parallelism;System and Safe Code .Reference and pointerGenerics parallel loopInferenceLoops 1 foreach( i; parallel( list ) ){ …}Functions .DebugsVersionsRequirement Pool threadEditors 1 void myfunction( int param1, int param 2 ){ …} 2 auto myTask = task!myfunction( param1, param2 );Basics 3 taskPool.put( myTask );My first D program 4 doSomething(); // another work in parallelTypes 5 taskPool.finish( true ); // wait alls jobs endingArrays .String and characters .Const and ImmutableInput/OutputAlgorithmStructure and ClassTemplateMiscellanous . . . .. . 15/122 .Let start it! D Programming . . . . Back . . . . . Forward .GTK D
  32. 32. D ProgrammingJonathan MERCIER Plan .. 1 IntroductionIntroduction ObjectObject FunctionalFunctional Meta-programmingMeta-programming ParallelismParallelism Ressource ManagementRessource Management Contract System and Safe CodeContract Reference and pointerSystem and Safe Code GenericsReference and pointer InferenceGenerics LoopsInference FunctionsLoops DebugsFunctions VersionsDebugs RequirementVersions EditorsRequirement . 2 BasicsEditors My first D program TypesBasics ArraysMy first D program String and charactersTypes Const and ImmutableArrays Input/OutputString and characters AlgorithmConst and Immutable Structure and ClassInput/Output TemplateAlgorithm MiscellanousStructure and Class Let start it! . 3 GTK DTemplate . 4 Thanks ToMiscellanous . . . . . . . 16/122 .Let start it! D Programming . . . . Back . . . . . Forward .GTK D
  33. 33. D ProgrammingJonathan MERCIER Ressource ManagementIntroductionObjectFunctionalMeta-programmingParallelismRessource ManagementContractSystem and Safe CodeReference and pointer Code 2: ExampleGenericsInference 1 File f = File( ”myfile.txt”, ”r”);Loops 2 scope(exit) f.close(); 3 lockFile( f );Functions 4 doFoo( f );Debugs 5 scope(success) doBar( f );Versions 6 scope(failure) unlock( f );RequirementEditors .BasicsMy first D programTypesArraysString and charactersConst and ImmutableInput/OutputAlgorithmStructure and ClassTemplateMiscellanous . . . . . . . 17/122 .Let start it! D Programming . . . . Back . . . . . Forward .GTK D
  34. 34. D ProgrammingJonathan MERCIER Plan .. 1 IntroductionIntroduction ObjectObject FunctionalFunctional Meta-programmingMeta-programming ParallelismParallelism Ressource ManagementRessource Management Contract System and Safe CodeContract Reference and pointerSystem and Safe Code GenericsReference and pointer InferenceGenerics LoopsInference FunctionsLoops DebugsFunctions VersionsDebugs RequirementVersions EditorsRequirement . 2 BasicsEditors My first D program TypesBasics ArraysMy first D program String and charactersTypes Const and ImmutableArrays Input/OutputString and characters AlgorithmConst and Immutable Structure and ClassInput/Output TemplateAlgorithm MiscellanousStructure and Class Let start it! . 3 GTK DTemplate . 4 Thanks ToMiscellanous . . . . . . . 18/122 .Let start it! D Programming . . . . Back . . . . . Forward .GTK D
  35. 35. D ProgrammingJonathan MERCIER ContractIntroductionObject .Functional check a statementMeta-programming 1 assert( var != null );ParallelismRessource Management .ContractSystem and Safe CodeReference and pointerGenericsInferenceLoopsFunctionsDebugsVersionsRequirementEditorsBasicsMy first D programTypesArraysString and charactersConst and ImmutableInput/OutputAlgorithmStructure and Class .TemplateMiscellanous . . . . . . . 19/122 .Let start it! D Programming . . . . Back . . . . . Forward .GTK D
  36. 36. D ProgrammingJonathan MERCIER ContractIntroductionObject .Functional check a statementMeta-programming 1 assert( var != null );ParallelismRessource Management .ContractSystem and Safe Code check before entering into a functionReference and pointer 1 double foo ( int a )Generics 2 in{ assert( a > 0 ); }Inference 3 body { return a − 2; }LoopsFunctions .DebugsVersionsRequirementEditorsBasicsMy first D programTypesArraysString and charactersConst and ImmutableInput/OutputAlgorithmStructure and Class .TemplateMiscellanous . . . . . . . 19/122 .Let start it! D Programming . . . . Back . . . . . Forward .GTK D
  37. 37. D ProgrammingJonathan MERCIER ContractIntroductionObject .Functional check a statementMeta-programming 1 assert( var != null );ParallelismRessource Management .ContractSystem and Safe Code check before entering into a functionReference and pointer 1 double foo ( int a )Generics 2 in{ assert( a > 0 ); }Inference 3 body { return a − 2; }LoopsFunctions .DebugsVersions check at function exitRequirement 1 int foo ( int a )Editors 2 out{ assert( a > 0 ); } 3 body { return a − 2; }BasicsMy first D program .TypesArraysString and charactersConst and ImmutableInput/OutputAlgorithmStructure and Class .TemplateMiscellanous . . . . . . . 19/122 .Let start it! D Programming . . . . Back . . . . . Forward .GTK D
  38. 38. D ProgrammingJonathan MERCIER ContractIntroductionObject .Functional check a statementMeta-programming 1 assert( var != null );ParallelismRessource Management .ContractSystem and Safe Code check before entering into a functionReference and pointer 1 double foo ( int a )Generics 2 in{ assert( a > 0 ); }Inference 3 body { return a − 2; }LoopsFunctions .DebugsVersions check at function exitRequirement 1 int foo ( int a )Editors 2 out{ assert( a > 0 ); } 3 body { return a − 2; }BasicsMy first D program . -release flag will not compute contractTypesArraysString and charactersConst and Immutable $ ldc2 -release foo.dInput/Output .AlgorithmStructure and Class .TemplateMiscellanous . . . . . . . 19/122 .Let start it! D Programming . . . . Back . . . . . Forward .GTK D
  39. 39. D ProgrammingJonathan MERCIER Plan .. 1 IntroductionIntroduction ObjectObject FunctionalFunctional Meta-programmingMeta-programming ParallelismParallelism Ressource ManagementRessource Management Contract System and Safe CodeContract Reference and pointerSystem and Safe Code GenericsReference and pointer InferenceGenerics LoopsInference FunctionsLoops DebugsFunctions VersionsDebugs RequirementVersions EditorsRequirement . 2 BasicsEditors My first D program TypesBasics ArraysMy first D program String and charactersTypes Const and ImmutableArrays Input/OutputString and characters AlgorithmConst and Immutable Structure and ClassInput/Output TemplateAlgorithm MiscellanousStructure and Class Let start it! . 3 GTK DTemplate . 4 Thanks ToMiscellanous . . . . . . . 20/122 .Let start it! D Programming . . . . Back . . . . . Forward .GTK D
  40. 40. D ProgrammingJonathan MERCIER System and Safe CodeIntroductionObjectFunctional .Meta-programming System and Safe CodeParallelism .Ressource ManagementContract Safe functions are functions that are statically checkedSystem and Safe CodeReference and pointer to have no possibility of undefined behavior.GenericsInferenceLoopsFunctionsDebugs Undefined behavior is often used as a vector forVersionsRequirement malicious attacks.EditorsBasicsMy first D programTypesArrays Func­tions are marked with at­tributes: @safe,String and charactersConst and Immutable @system, @trusted .Input/OutputAlgorithmStructure and ClassTemplateMiscellanous . . . . . . . . 21/122 .Let start it! D Programming . . . . Back . . . . . Forward .GTK D
  41. 41. D ProgrammingJonathan MERCIER Plan .. 1 IntroductionIntroduction ObjectObject FunctionalFunctional Meta-programmingMeta-programming ParallelismParallelism Ressource ManagementRessource Management Contract System and Safe CodeContract Reference and pointerSystem and Safe Code GenericsReference and pointer InferenceGenerics LoopsInference FunctionsLoops DebugsFunctions VersionsDebugs RequirementVersions EditorsRequirement . 2 BasicsEditors My first D program TypesBasics ArraysMy first D program String and charactersTypes Const and ImmutableArrays Input/OutputString and characters AlgorithmConst and Immutable Structure and ClassInput/Output TemplateAlgorithm MiscellanousStructure and Class Let start it! . 3 GTK DTemplate . 4 Thanks ToMiscellanous . . . . . . . . 22/122 .Let start it! D Programming . . . . Back . . . . . Forward .GTK D
  42. 42. D ProgrammingJonathan MERCIER Reference and pointerIntroductionObjectFunctionalMeta-programmingParallelismRessource Management .Contract Pointers exist only to create C interface codeSystem and Safe Code 1 int* a = cFunction( param );Reference and pointerGenerics .InferenceLoopsFunctionsDebugsVersionsRequirementEditorsBasicsMy first D programTypes .ArraysString and charactersConst and ImmutableInput/OutputAlgorithmStructure and ClassTemplateMiscellanous . . . . . . . . 23/122 .Let start it! D Programming . . . . Back . . . . . Forward .GTK D
  43. 43. D ProgrammingJonathan MERCIER Reference and pointerIntroductionObjectFunctionalMeta-programmingParallelismRessource Management .Contract Pointers exist only to create C interface codeSystem and Safe Code 1 int* a = cFunction( param );Reference and pointerGenerics .InferenceLoops ref into functionFunctions 1 void foo( ref int[] param ) { …}DebugsVersions .RequirementEditorsBasicsMy first D programTypes .ArraysString and charactersConst and ImmutableInput/OutputAlgorithmStructure and ClassTemplateMiscellanous . . . . . . . . 23/122 .Let start it! D Programming . . . . Back . . . . . Forward .GTK D
  44. 44. D ProgrammingJonathan MERCIER Reference and pointerIntroductionObjectFunctionalMeta-programmingParallelismRessource Management .Contract Pointers exist only to create C interface codeSystem and Safe Code 1 int* a = cFunction( param );Reference and pointerGenerics .InferenceLoops ref into functionFunctions 1 void foo( ref int[] param ) { …}DebugsVersions .RequirementEditors ref into a loopBasics 1 foreach( ref item ; list ){ …} .My first D programTypes .ArraysString and charactersConst and ImmutableInput/OutputAlgorithmStructure and ClassTemplateMiscellanous . . . . . . . . 23/122 .Let start it! D Programming . . . . Back . . . . . Forward .GTK D
  45. 45. D ProgrammingJonathan MERCIER Plan .. 1 IntroductionIntroduction ObjectObject FunctionalFunctional Meta-programmingMeta-programming ParallelismParallelism Ressource ManagementRessource Management Contract System and Safe CodeContract Reference and pointerSystem and Safe Code GenericsReference and pointer InferenceGenerics LoopsInference FunctionsLoops DebugsFunctions VersionsDebugs RequirementVersions EditorsRequirement . 2 BasicsEditors My first D program TypesBasics ArraysMy first D program String and charactersTypes Const and ImmutableArrays Input/OutputString and characters AlgorithmConst and Immutable Structure and ClassInput/Output TemplateAlgorithm MiscellanousStructure and Class Let start it! . 3 GTK DTemplate . 4 Thanks ToMiscellanous . . . . . . . . 24/122 .Let start it! D Programming . . . . Back . . . . . Forward .GTK D
  46. 46. D ProgrammingJonathan MERCIER . GenericIntroduction .Object classFunctional 1 class Foo( T ){ …}Meta-programming 2 Foo!int instance = new Foo!(int)( param );Parallelism .Ressource ManagementContractSystem and Safe CodeReference and pointerGenericsInferenceLoopsFunctionsDebugsVersionsRequirementEditorsBasicsMy first D programTypesArraysString and charactersConst and ImmutableInput/Output .AlgorithmStructure and ClassTemplateMiscellanous . . . . .. . . 25/122 .Let start it! D Programming . . . . Back . . . . . Forward .GTK D
  47. 47. D ProgrammingJonathan MERCIER . GenericIntroduction .Object classFunctional 1 class Foo( T ){ …}Meta-programming 2 Foo!int instance = new Foo!(int)( param );Parallelism .Ressource ManagementContractSystem and Safe Code structureReference and pointer 1 struct Foo( T ){ …}Generics 2 Foo!int instance = Foo!int( param );Inference .LoopsFunctionsDebugsVersionsRequirementEditorsBasicsMy first D programTypesArraysString and charactersConst and ImmutableInput/Output .AlgorithmStructure and ClassTemplateMiscellanous . . . . .. . . 25/122 .Let start it! D Programming . . . . Back . . . . . Forward .GTK D
  48. 48. D ProgrammingJonathan MERCIER . GenericIntroduction .Object classFunctional 1 class Foo( T ){ …}Meta-programming 2 Foo!int instance = new Foo!(int)( param );Parallelism .Ressource ManagementContractSystem and Safe Code structureReference and pointer 1 struct Foo( T ){ …}Generics 2 Foo!int instance = Foo!int( param );Inference .LoopsFunctions functionDebugs 1 T foo( T )(T param){ …}Versions 2 int var = foo!int( param );RequirementEditors .BasicsMy first D programTypesArraysString and charactersConst and ImmutableInput/Output .AlgorithmStructure and ClassTemplateMiscellanous . . . . .. . . 25/122 .Let start it! D Programming . . . . Back . . . . . Forward .GTK D
  49. 49. D ProgrammingJonathan MERCIER . GenericIntroduction .Object classFunctional 1 class Foo( T ){ …}Meta-programming 2 Foo!int instance = new Foo!(int)( param );Parallelism .Ressource ManagementContractSystem and Safe Code structureReference and pointer 1 struct Foo( T ){ …}Generics 2 Foo!int instance = Foo!int( param );Inference .LoopsFunctions functionDebugs 1 T foo( T )(T param){ …}Versions 2 int var = foo!int( param );RequirementEditors .Basics macroMy first D program 1 template TFoo( T )( T param ){ immutable T f = param + 3;Types }Arrays 2 int a = TFoo!int( 4 ) ; // return 7 at compile timeString and characters .Const and ImmutableInput/Output .AlgorithmStructure and ClassTemplateMiscellanous . . . . .. . . 25/122 .Let start it! D Programming . . . . Back . . . . . Forward .GTK D

×