오브젝트 파스칼

오브젝트 파스칼(Object Pascal)은 파스칼객체 지향 개념을 포함하여 발전시킨 프로그래밍 언어이다. 주로 델파이 언어로도 잘 알려져 있다.

오브젝트 파스칼
패러다임명령형 절차적 구조적 객체지향
발표일1986년(38년 전)(1986)
운영 체제크로스 플랫폼
파일 확장자.p, .pp, .pas
델파이
영향을 받은 언어
파스칼

애플 매킨토시의 전신인 애플 리자용으로 개발한 오브젝트 파스칼 컴파일러가 시초이며, 가장 널리 알려진 오브젝트 파스칼의 변종은 볼랜드/코드기어 사의 델파이에서 사용되는 '델파이 프로그래밍 언어'가 있다. 볼랜드/코드기어 외 제품으로서는 자유 소프트웨어로 개발되는 델파이와 매우 닮은 프리 파스칼도 거의 유사한 문법을 가지고 있다.

Hello World 프로그램 편집

애플의 오브젝트 파스칼 편집

program ObjectPascalExample;

   type
      THelloWorld = object
         procedure Put;
      end;

   var
      HelloWorld: THelloWorld;

   procedure THelloWorld.Put;
   begin
      WriteLn('Hello, World!');
      ReadLn;
   end;

begin
   New(HelloWorld);
   HelloWorld.Put;
   Dispose(HelloWorld);
end.

터보 파스칼 편집

program ObjectPascalExample;

   type
      PHelloWorld = ^THelloWorld;
      THelloWorld = object
         procedure Put;
      end;

   var
      HelloWorld: PHelloWorld; { this is a pointer to a THelloWorld }

   procedure THelloWorld.Put;
   begin
      WriteLn('Hello, World!');
   end;

begin
   New(HelloWorld);
   HelloWorld^.Put;
   Dispose(HelloWorld);
end.

델파이, 프리 파스칼 편집

program ObjectPascalExample;
{$MODE DELPHI}  { Only for free pascal or compile option -Mdelphi }
type
  THelloWorld = class
    procedure Put;
  end;

procedure THelloWorld.Put;
begin
  Writeln('Hello, World!');
end;

var
  HelloWorld: THelloWorld;               { this is an implicit pointer }

begin
  HelloWorld := THelloWorld.Create;      { constructor returns a pointer }
  HelloWorld.Put;
  HelloWorld.Free;                       { this line dereferences the pointer }
end.

같이 보기 편집

외부 링크 편집