Delphi

From YYpBD's MediaWiki

Jump to: navigation, search

Object Pascal을 기본 언어로 쓰는 Borland사의 개발툴이다.

CodeGear가 Borland에서 분사하여 계속 개발중이다.

RAD 계열툴 중 최고의 생산성을 자랑하며 Visual C++과 맞먹는 강력한 성능을 발휘한다.

목차

Delphi 2009

Generics

Data

type
  SomeArray<ParamType> = array of ParamType;
  IntegerArray = SomeArray<Integer>;

type
  Some<T: TComponent> = array of T; // TComponent를 상속받은 형만 설정가능
  LabelArray = Some<TLabel>;
  //DWordArray = Some<DWORD>;  // Error

Function

    procedure Exchange<T>(var A, B: T);


procedure TForm1.Exchange<T>(var A, B: T);
var
  i: T;
begin
  i := A;
  A := B;
  B := i;
end;

procedure TForm1.Button1Click(Sender: TObject);
var
  a, b: Integer;
begin
  a := 10;
  b := 20;

  Exchange<Integer>( a, b );

  ShowMessage( IntToStr(a) + ', ' + IntToStr(b) );
end;

Class


  TGeneric<AnyType> = class
    class procedure Swap(var X,Y: AnyType);
  end;

class procedure TGeneric<AnyType>.Swap(var X, Y: AnyType);
var
  Temp: AnyType;
begin
  Temp := X;
  X := Y;
  Y := Temp;
end;

procedure TForm1.Button2Click(Sender: TObject);
var
  a, b: Integer;
begin
  a := 10;
  b := 20;

  TGeneric<Integer>.Swap( A, B );

  ShowMessage( IntToStr(a) );
  ShowMessage( IntToStr(b) );
end;

Anonymous Methods


type
  TProc = reference to procedure(x: Integer);

procedure call(const proc: TProc);
begin
  proc(42);
end;

procedure TForm2.Button2Click(Sender: TObject);
var
  proc: TProc;
begin
  proc := procedure(a: Integer)
  begin
    Button2.Caption := IntToStr(a)
  end;
  call(proc)
end;

Link

국내 사이트

해외 사이트

Library

Component

Extend Tool

맞춤검색