Presentation is loading. Please wait.

Presentation is loading. Please wait.

Delphi 2009의 언어 개선 박지훈.임프 2018년 11월 16일 금요일

Similar presentations


Presentation on theme: "Delphi 2009의 언어 개선 박지훈.임프 2018년 11월 16일 금요일"— Presentation transcript:

1 Delphi 2009의 언어 개선 박지훈.임프 cbuilder1@borlandforum.com 2018년 11월 16일 금요일

2 목차 Generics Anonymous Methods : closure 기타 Exit Default
2018년 11월 16일 금요일 2

3 Generics (제네릭) 2018년 11월 16일 금요일

4 Generics ? 정의 C++ Delphi 2007 for .NET
“a style of computer programming in which algorithms are written in terms of to-be-specified-later types” (Wikipedia) a set of abstraction tools that permit the decoupling of an algorithm (procedure, function) or a data structure (class, interface, record) from one or more concrete types (Delphi 2009 Help) C++ template Delphi 2007 for .NET CLR의 generics 아키텍처를 이용 (C# 2.0) reusability, abstraction, polymorphism 2018년 11월 16일 금요일

5 Generic화의 대상 Generic class, interface, record Generic method
Generic procedure type 2018년 11월 16일 금요일

6 Generic class, interface, record
type     TPair<TKey, TValue> = class     FKey: TKey;     FValue: TValue;     function GetValue: TValue;   end; function TPair<TKey, TValue>.GetValue: TValue; begin   result := FValue; end; procedure TForm1.FormCreate(Sender: TObject); var     MyPair: TPair<string, integer>;   MyPair := TPair<string, integer>.Create; type parameter / type argument 2018년 11월 16일 금요일

7 Generic method type TFoo = class function GenericFunction<T>: T;
    procedure GenericMethod<T>(A: T);   end; function TFoo.GenericFunction<T>: T; begin Result := Default(T); end; procedure TFoo.GenericMethod<T>(A: T); ShowMessage('aa'); method overload와 비슷한 역할을 하며, 더 간략해진다 Default 2018년 11월 16일 금요일

8 Generic procedure type
TMyProc<T> = procedure(Param: T); procedure Sample(Param: Integer); begin WriteLn(Param); end; procedure TFoo.Test; var X: TMyProc<Integer>; X := Sample; X(10); 2018년 11월 16일 금요일

9 Generics in RTL Generics.Defaults.pas Generics.Collections.pas
TPair, TList TQueue, TStack TPair, TDictionary TObjectList, TObjectQueue, TObjectStack, TObjectDictionary 2018년 11월 16일 금요일

10 Demo Generics.Collections.pas, TList<T> 2018년 11월 16일 금요일

11 Anonymous Methods (익명 메소드)
2018년 11월 16일 금요일

12 Anonymous Methods? 정의 closure
“a procedure or function that does not have a name associated with it” “treats a block of code as an entity that can be assigned to a variable or used as a parameter to a method” “can refer to variables and bind values to the variables in the context in which the method is defined “ closure 2018년 11월 16일 금요일

13 Anonymous Methods? 정의 Closure
“procedure or function that does not have a name associated with it” “treats a block of code as an entity that can be assigned to a variable or used as a parameter to a method” “can refer to variables and bind values to the variables in the context in which the method is defined” Closure functional programming style .NET (Anonymous Methods) 2018년 11월 16일 금요일

14 Anonymous Methods 장점 코드가 간략해짐 Inline - Local 변수 액세스 가능
내부 함수/프로시저와 비슷, 하지만 전달되는 인자들이 직접 전달되느냐 복사되느냐 2018년 11월 16일 금요일

15 Demo Generics.Collections.pas, TList<T> 2018년 11월 16일 금요일

16 Q&A 2018년 11월 16일 금요일

17 2018년 11월 16일 금요일 17


Download ppt "Delphi 2009의 언어 개선 박지훈.임프 2018년 11월 16일 금요일"

Similar presentations


Ads by Google