Movatterモバイル変換


[0]ホーム

URL:


Wikipedia

Object Pascal

This articleneeds additional citations forverification. Please helpimprove this article byadding citations to reliable sources. Unsourced material may be challenged and removed.
Find sources: "Object Pascal" – news ·newspapers ·books ·scholar ·JSTOR
(May 2019) (Learn how and when to remove this message)

Object Pascal is an extension to the programming languagePascal that providesobject-oriented programming (OOP) features such asclasses andmethods.

Object Pascal
ParadigmsImperative,structured,object-oriented,functional (Delphi dialect only),component-based,event-driven,generic
FamilyWirthPascal
Designed byLarry Tesler (Apple)
Niklaus Wirth (for Apple)
Anders Hejlsberg (Borland)[1]
DevelopersApple Computer (initial)
Borland International[1]
First appeared1986; 39 years ago (1986)
Typing disciplineStatic and dynamic (dynamic typing through variants,array of const, andRTTI),strong,safe
ScopeLexical (static)
PlatformARM,x86,PowerPC,ppc64,SPARC,MIPS,CLI,Java
Filename extensions.p,.pp,.pas
Majorimplementations
Delphi (x86,ARM),Free Pascal (x86,PowerPC,ppc64,SPARC,MIPS,ARM),Oxygene (CLI,Java, NativeCocoa), Smart Mobile Studio (JavaScript)
Dialects
Apple,Turbo Pascal,Free Pascal (usingobjfpc ordelphi mode),Delphi, Delphi.NET, Delphi Web Script,PascalABC.NET,Oxygene
Influenced by
Pascal,Simula,Smalltalk
Influenced
C#, Genie,Java,Nim,C/AL

The language was originally developed byApple Computer asClascal for theLisa Workshop development system. As Lisa gave way toMacintosh, Apple collaborated withNiklaus Wirth, the author of Pascal, to develop an officially standardized version of Clascal. This was renamed Object Pascal. Through the mid-1980s, Object Pascal was the main programming language for early versions of theMacAppapplication framework. The language lost its place as the main development language on the Mac in 1991 with the release of theC++-based MacApp 3.0. Official support ended in 1996.

Symantec also developed acompiler for Object Pascal for their Think Pascal product, which could compile programs much faster than Apple's ownMacintosh Programmer's Workshop (MPW). Symantec then developed the Think Class Library (TCL), based on MacApp concepts, which could be called from both Object Pascal andTHINK C. The Think suite largely displaced MPW as the main development platform on the Mac in the late 1980s.

Symantec ported Object Pascal to the PC, and developed a similar object framework on that platform. In contrast to TCL, which eventually migrated to C++, the PClibraries remained mainly based on Pascal.

Borland added support for object-oriented programming toTurbo Pascal 5.5, which would eventually become the basis for the Object Pascal dialect used inDelphi created byAnders Hejlsberg. Delphi remained mainstream for business applications on the PC into the early 2000s, and was partly displaced in the 2000s with the introduction of the.NET Framework which included Hejlsberg'sC#.

History

edit

Apple Pascal

edit

Pascal became a major language in the programming world in the 1970s, with high-quality implementations on mostminicomputer platforms andmicrocomputers. Among the latter was theUCSD Pascal system, which compiled to an intermediatep-System code format that could then run on multiple platforms. Apple licensed UCSD and used it as the basis for theirApple Pascal system for theApple II andApple III.

Pascal became one of the major languages in the company in this period. With the start of theApple Lisa project, Pascal was selected as the main programming language of the platform, although this time as acompiler in contrast to the p-Systeminterpreter.

Clascal and Apple's early Object Pascal

edit

Object Pascal is an extension of the Pascal language that was developed atApple Computer by a team led byLarry Tesler in consultation withNiklaus Wirth, the inventor of Pascal.[2][3] It is descended from an earlier object-oriented version of Pascal namedClascal, which was available on theLisa computer.

Object Pascal was needed to supportMacApp, an expandable Macintosh application framework that would now be termed aclass library. Object Pascal extensions, and MacApp, were developed by Barry Haynes, Ken Doyle, and Larry Rosenstein, and were tested by Dan Allen. Larry Tesler oversaw the project, which began very early in 1985 and became a product in 1986.

An Object Pascal extension was also implemented in the Think Pascalintegrated development environment (IDE). The IDE includes the compiler and an editor withsyntax highlighting and checking, a powerfuldebugger, and a class library.[4] Many developers preferred Think Pascal over Apple's implementation of Object Pascal because Think Pascal offered a much faster compile–link–debug cycle, and tight integration of its tools. The last official release of Think Pascal was 4.01, in 1992.Symantec later released an unofficial version 4.5d4 at no charge.

Apple dropped support for Object Pascal when they moved fromMotorola 68000 series chips to IBM'sPowerPC architecture in 1994. MacApp 3.0, had already been rewritten inC++ and ported to this platform.

Metrowerks offered withCodeWarrior an Object Pascal compiler for Macintosh that targeted both68k andPowerPC, both in their IDE and as MPW tools. Macintosh developers using Object Pascal had a path to port to thePowerPC, even architecture after both Apple and Symantec dropped support.MacApp 2.0, written in Object Pascal, was ported to the PowerPC usingCodeWarrior.[5][6]

Borland, Inprise, CodeGear, and Embarcadero years

edit

In 1986,Borland introduced similar extensions, also named Object Pascal, to theTurbo Pascal product for the Macintosh, and in 1989 for Turbo Pascal 5.5 for DOS. When Borland refocused fromDOS toWindows in 1994, they created a successor to Turbo Pascal, namedDelphi, and introduced a new set of extensions to create what is now known as the Delphi language.

The development of Delphi started in 1993 and Delphi 1.0 was officially released in the United States on 14 February 1995. While code using the Turbo Pascal object model could still be compiled, Delphi featured a new syntax using the keywordclass in preference toobject, the Create constructor and a virtual Destroy destructor (and negating having to call theNew andDispose procedures), properties, method pointers, and some other things. These were inspired by theISO workingdraft for object-oriented extensions, but many of the differences from Turbo Pascal's dialect (such as the draft's requirement that all methods bevirtual) were ignored.[citation needed]

The Delphi language has continued to evolve over the years to support constructs such asdynamic arrays,generics andanonymous methods. The old object syntax introduced by Apple ("Old-Style Object Types") is still supported.[7]

Versions

edit

Compilers

edit

Object Pascalcompilers are available for a wide range ofoperating systems and architectures.

  • Delphi is probably the best known compiler. It is the successor of the highly successful Borland Pascal andTurbo Pascal product line. It targetsWindows 9x (Delphi 2007 and older), theWindows NT family,.NET Framework (Delphi 8, 2005, 2007),macOS (Delphi XE2 and later),iOS (Delphi XE2 and later, generating native binaries in XE4 and later),Android (Delphi XE5 and later, generating native binaries in XE5 and later). Support for .NET finally became a separate product known as Oxygene (see below).
  • Free Pascal Compiler (FPC) is an open-source Object Pascal compiler that supports many Pascal dialects, includingTurbo Pascal 7, Delphi, and others. Currently, FPC can generate code forIA-32,x86-64,PowerPC,SPARC, andARM processors, and for several operating systems, includingMicrosoft Windows,Linux,FreeBSD,Classic Mac OS, andmacOS (with anXcode integration kit). Several separate projects exist to facilitate rapid application development with FPC, the most prominent one beingLazarus (IDE).
  • GNU Pascal (a separately distributed part of theGNU Compiler Collection), while not formally aimed at the Delphi dialect of Pascal, does contain a Turbo Pascal compatibility mode, and is very slowly incorporating a few Delphi language features. It is unsuitable for recompiling large bodies of Delphi code directly, but is notable as having prolific support for operating systems and hardware architectures.
  • Oxygene (formerlyChrome) is an Object Pascal compiler fromRemObjects Software that integrates intoMicrosoft Visual Studio. It is also available as freecommand-line interface compiler that runs native onCLI. It is three compilers in one, each targeting a different platform: Echoes for.NET Framework,Mono,WinRT andWindows Phone 8, Cooper forJDK andAndroid, and Nougat foriOS andmacOS.

Legacy products

edit
  • Borland Kylix was aLinux variant of Delphi which only targets Intel 32-bit Linux using theQt library. It does not work out of the box with most modern Linux distributions.
  • Virtual Pascal was a free 32-bit Turbo Pascal and Delphi compatible compiler for mainlyOS/2 and Microsoft Windows. Later, it also received a DOS+ Extender and an experimental Linux cross-compiler. The compiler's development stopped at about the level of Delphi 2. In 2007, its official website ceased to operate, and further development ceased.

Interpreters

edit
Main article:Pascal Script

Pascal Script (formerlyInnerFuse) andDWScript (Delphi Web Script) are open-source Object Pascalinterpreters and scripting engines written in Delphi. They support subsets of Object Pascal. DWScript can also compile Object Pascal code into JavaScript code (Smart Pascal), and supportsjust-in-time compilation (JIT). Modern Pascal provides 3 different interpreters: acommand-line interface (CLI), Apache Module (Celerity), and CodeRunner (node.js like solution able to handle different scripts per port), besides the ability to compile and protect a script'ssource code.[16]

Sample "Hello World" programs

edit
This sectiondoes notcite anysources. Please helpimprove this section byadding citations to reliable sources. Unsourced material may be challenged andremoved.(June 2013) (Learn how and when to remove this message)

Here are several "Hello World" programs in different Object Pascal versions.

Apple version

edit
programObjectPascalExample;typeTHelloWorld=objectprocedurePut;end;varHelloWorld:THelloWorld;procedureTHelloWorld.Put;beginShowMessage('Hello, World!');end;beginNew(HelloWorld);HelloWorld.Put;Dispose(HelloWorld);end.

Turbo Pascal version

edit

Still supported in Delphi and Free Pascal. FPC also packages its own substitutes for the libraries/units. Delphi does not. The Free Pascal 1.0 series and the FPC textmode IDE are the largest open codebases in this dialect. Free Pascal 2.0 was rewritten in a more Delphi-like dialect, and the textmode IDE and related frameworks (Free Vision) are the only parts in the TP version of Object Pascal.

Stack based allocation

edit
programObjectPascalExample;typeTHelloWorld=objectprocedurePut;end;procedureTHelloWorld.Put;beginWriteLn('Hello, World!');end;varHelloWorld:THelloWorld;{ allocated on the stack and can be used without explicit allocation. }beginHelloWorld.Put;end.

Heap based allocation

edit
programObjectPascalExample;typePHelloWorld=^THelloWorld;THelloWorld=objectprocedurePut;end;procedureTHelloWorld.Put;beginWriteLn('Hello, World!');end;varHelloWorld:PHelloWorld;{ this is a typed pointer to a THelloWorld }beginNew(HelloWorld);HelloWorld^.Put;Dispose(HelloWorld);end.

Another example:

programObjectPascalExample;typePHelloWorld=^THelloWorld;THelloWorld=objectprocedurePut;end;procedureTHelloWorld.Put;beginWriteLn('Hello, World!');end;varHelloWorld:PHelloWorld;{ this is a typed pointer to a THelloWorld }HelloWorld2:^THelloWorld;{ this is exactly the same with different syntax }HelloWorld3:^THelloWorld;HelloWorld4:PHelloWorld;begin{ This works in a similar way as the code above, note the allocation and de-allocation, though,     many people get confused. In the past there was a wrong example with wrong comments here... }New(HelloWorld);{ one instance }HelloWorld4:=HelloWorld;{ this is valid - a pointer copy }HelloWorld2:=HelloWorld;{ this is valid - a pointer copy }New(HelloWorld3);{ a second instance }HelloWorld4:=HelloWorld3;{ this is valid - a pointer copy }HelloWorld2:=HelloWorld3;{ this is valid - a pointer copy }Dispose(HelloWorld);{ it allocates only two instances }Dispose(HelloWorld3);{ so it must release only two instances }end.

This works based on pointer copy, unless there is a specific allocation for a deeper copy.

Delphi and Free Pascal version

edit
programObjectPascalExample;typeTHelloWorld=classprocedurePut;end;procedureTHelloWorld.Put;beginWriteln('Hello, World!');end;varHelloWorld:THelloWorld;{ this is an implicit pointer }beginHelloWorld:=THelloWorld.Create;{ constructor returns a pointer to an object of type THelloWorld }HelloWorld.Put;HelloWorld.Free;{ this line deallocates the THelloWorld object pointed to by HelloWorld }end.

Note that the object construct is still available in Delphi and Free Pascal.

Oxygene version

edit
namespaceObjectPascalExample;interfacetypeConsoleApp=classclassmethodMain;end;THelloWorld=classmethodPut;end;implementationmethodTHelloWorld.Put;beginConsole.WriteLine('Hello, World!');end;classmethodConsoleApp.Main;beginvarHelloWorld:=newTHelloWorld;HelloWorld.Put;end;end.

DWScript (Smart Pascal) version

edit
typeTHelloWorld=classprocedurePut;beginPrintLn('Hello, World!');endend;varHelloWorld:=THelloWorld.Create;HelloWorld.Put;

The method implementation can also be made in a distinct location as in other Object Pascal dialects.

Development

edit

Many features have been introduced continuously to Object Pascal with extensions to Delphi and extensions to FreePascal. In reaction to criticism, Free Pascal has adopted generics with the same syntax as Delphi, provided Delphi compatibility mode is selected, and both Delphi (partial) and Free Pascal (more extensive) supportoperator overloading. Delphi has also introduced many other features since version 7,[17] including generics. Whereas FreePascal tries to be compatible to Delphi in Delphi compatibility mode, it also usually introduced many new features to the language that are not always available in Delphi.

References

edit
  1. ^abGibson, Steve (May 8, 1989)."Borland and Microsoft Enter the Object-Oriented Pascal Ring".InfoWorld. Vol. 11, no. 19. p. 28.Archived from the original on February 29, 2024. RetrievedSeptember 18, 2021.
  2. ^Tesler, Larry (1985). "Object Pascal Report".Structured Language World.9 (3):10–7.
  3. ^Tesler, Larry (February 4, 1985)."Object Pascal for the Macintosh"(PDF). RetrievedMarch 13, 2025.
  4. ^Seiter, Charles (November 1990)."Think Pascal 3".Macworld. Vol. 7, no. 11. p. 236.
  5. ^Arnold, Brian; McCarthy, Guy (November 1995)."MacApp Pascal Rides again".MacTech. Vol. 11, no. 11. pp. 30–31.
  6. ^Arnold, Brian (February 1996)."MacApp 2 for PowerPC in Object Pascal".MacTech. Vol. 12, no. 2. pp. 25–32.
  7. ^Lischner, Ray (2000).Delphi in a nutshell: a desktop quick reference (1st ed.). Sebastopol, CA: O'Reilly and Associates.ISBN 1565926595.
  8. ^Community Letter: Embarcadero Technologies agrees to acquire CodeGear from BorlandArchived 2018-03-02 at theWayback Machine. Edn.embarcadero.com. Retrieved on 2013-07-21.
  9. ^"iPhone/iPod development". Free Pascal development team.Archived from the original on 2009-04-28. Retrieved2009-04-13.
  10. ^A Smart Book. Leanpub. 18 May 2012.Archived from the original on 25 May 2013. Retrieved19 June 2013.
  11. ^Funa, Igor (2021)."Turbo51: Turbo Pascal Compiler for 8051 microcontrollers".Archived from the original on 2018-09-25.
  12. ^Draxler, Wolfgang."WDSibyl: Visual Development Environment".Archived from the original on 2020-02-12.
  13. ^"EDM/2: WDSibyl". Archived fromthe original on 2021-03-24.
  14. ^"EDM/2: List of Tools". Archived fromthe original on 2022-08-21.
  15. ^"eCSoft/2: The Complete OS/2 Software Encyclopedia: WDSibyl". Archived fromthe original on 2021-10-17.
  16. ^"Modern Pascal".Archived from the original on 2018-12-11. Retrieved2018-10-22.
  17. ^"New Delphi language features since Delphi 7". CodeGear.Archived from the original on 2008-07-02. Retrieved2008-07-06.

External links

edit

Delphi

edit

[8]ページ先頭

©2009-2025 Movatter.jp