Object Pascal

Object Pascal
Paradigma olio-ohjelmointi
Vaikutteet Pascal (ohjelmointikieli)
Murteet Delphi

Object Pascal on Pascal-ohjelmointikielen objektiorientoitunut johdannainen, joka tunnetaan parhaiten Borland Delphin kehitysympäristön alkuperäisenä ohjelmointikielenä. Delphi onkin tunnetuin Object Pascalin murre.

Borland käytti nimeä "Object Pascal" Delphin ensimmäisissä versioissa mutta myöhemmin nimesi sen uudestaan Delphi ohjelmointikieleksi. Monet Object Pascal -kääntäjät pyrkivät kuitenkin olemaan Delphin kanssa yhteensopivia.

Borlandin integroitu Delphi-kehitysympäristö on saatavana Microsoft Windows - ja Linux-alustoille. Avoimen lähdekoodin Free Pascal tukee Object Pascal -kehitystä Intel x86 (sisältäen 8086), AMD64/x86-64, PowerPC, PowerPC64, SPARC, ARM, AArch64, MIPS, JVM, Linux, FreeBSD, Haiku, Mac OS X/iOS/iPhoneSimulator/Darwin, DOS (16- ja 32-bittinen), Win32, Win64, WinCE, OS/2, MorphOS, Nintendo GBA, Nintendo DS, Wii, Android, AIX ja AROS.

Object Pascalin alku Apple-tietokoneissa

Object Pascalin historia alkoi Pascal-ohjelmointikielen laajennuksena, jonka Larry Teslerin johtama tiimi kehitti Applella yhteistyössä Pascalin keksijä Niklaus Wirthin kanssa. Se perustui aiempaan Apple Lisa -tietokoneessa käytettyyn Clascal-nimiseen oliopohjaiseen Pascal-versioon.

Apple lopetti Object Pascalin tukemisen siirtyessään Motorola 68000 -sarjan suorittimista PowerPC -suorittimiin 1994.

Borland aikakausi

Vuonna 1986 Borland julkisti Turbo Pascalin Macintosh-versioon objektilaajennuksen, jota se kutsui Object Pascaliksi. Se tuotiin myös MS-DOS-ympäristöön Turbo Pascal versiossa 5.5 vuonna 1989.

Windowsiin Object Pascal tuli Turbo Pascal for Windows -versiossa, ja vuonna 1994 Borland julkisti Turbo Pascalin seuraajan, Delphin. Delphissä Borland esitteli uusia objektilaajennuksia, joiden rakenne ja nimeäminen muistutti muissa objektiorientoituneissa kielissä käytettyjä, kuten class, constructor ja destructor.

Object Pascal kääntäjät

Object Pascalille on olemassa suuri joukko kääntäjiä, jotka ovat paremmin tai huonommin yhteensopivia Delphin Object Pascal -kääntäjän kanssa. Monet näistä kääntävät Object Pascal -lähdekoodia tietyille alustoille.

Hello World esimerkki

Applen Object Pascal

  program ObjectPascalExample;
  type
    THelloWorld = object
      procedure Put;
    end;
  var
    HelloWorld: THelloWorld;
  procedure THelloWorld.Put;
  begin
    WriteLn('Hello, World!');
  end;
  begin
    New(HelloWorld);
    HelloWorld.Put;
    Dispose(HelloWorld);
  end.

Turbo Pascalin Object Pascal

  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.

Delphin Object Pascal

  program ObjectPascalExample;
  type
    THelloWorld = class
      procedure Put;
    end;
  var
    HelloWorld: THelloWorld;
  procedure THelloWorld.Put;
  begin
    WriteLn('Hello, World!');
  end;
  begin
    HelloWorld := THelloWorld.Create;
    HelloWorld.Put;
    HelloWorld.Free;
  end.

Chromen Object Pascal

  namespace ObjectPascalExample;
  interface
  type
    ConsoleApp = class
      class method Main;
    end;
    THelloWorld = class
      method Put;
    end;
  implementation
  method THelloWorld.Put;
  begin
    Console.WriteLine('Hello, World!');
  end;
  class method ConsoleApp.Main;
  begin
    var HelloWorld := new THelloWorld;
    HelloWorld.Put;
  end;
  end.

Katso myös

Lähteet

  1. ↑ Free Pascal - Advanced open source Pascal compiler for Pascal and Object Pascal - Home Page www.freepascal.org. Viitattu 6.1.2016.

Aiheesta muualla

Johdanto Object Pascal kieleen:

Delphi Object Pascal kieliopas:

Free Pascal Object Pascal käsikirja:

GNU Pascal: