Object Pascal: Difference between revisions

From HandWiki
imported>DanMescoff
simplify
 
WikiIA2 (talk | contribs)
simplify
 
Line 12: Line 12:
| scope = [[Scope (computer science)|Lexical]] (static)
| scope = [[Scope (computer science)|Lexical]] (static)
| programming language =  
| programming language =  
| platform = [[ARM architecture family|ARM]], [[X86|x86]], [[PowerPC]], [[Ppc64|ppc64]], [[SPARC]], [[MIPS architecture|MIPS]], [[Common Language Infrastructure|CLI]], [[Software:Java (software platform)|Java]], Cocoa
| platform = [[ARM architecture family|ARM]], [[X86|x86]], [[PowerPC]], [[Ppc64|ppc64]], [[SPARC]], [[MIPS architecture|MIPS]], [[Common Language Infrastructure|CLI]], [[Software:Java (software platform)|Java]]
| operating system =  
| operating system =  
| license =  
| license =  
Line 21: Line 21:
| dialects = Apple, [[Software:Turbo Pascal|Turbo Pascal]], [[Software:Free Pascal|Free Pascal]] (using '''objfpc''' or '''delphi''' mode), [[Software:Delphi|Delphi]], Delphi.NET, Delphi Web Script, [[PascalABC.NET]], [[Oxygene (programming language)|Oxygene]]  
| dialects = Apple, [[Software:Turbo Pascal|Turbo Pascal]], [[Software:Free Pascal|Free Pascal]] (using '''objfpc''' or '''delphi''' mode), [[Software:Delphi|Delphi]], Delphi.NET, Delphi Web Script, [[PascalABC.NET]], [[Oxygene (programming language)|Oxygene]]  
| influenced by = [[Pascal (programming language)|Pascal]], [[Simula]], [[Smalltalk]]
| influenced by = [[Pascal (programming language)|Pascal]], [[Simula]], [[Smalltalk]]
| influenced = [[C Sharp (programming language)|C#]], [[Genie (programming language)|Genie]], [[Java (programming language)|Java]], [[Nim (programming language)|Nim]], C/AL
| influenced = [[C Sharp (programming language)|C#]], Genie, [[Java (programming language)|Java]], [[Nim (programming language)|Nim]], C/AL
}}
}}


'''Object Pascal''' is an extension to the programming language [[Pascal (programming language)|Pascal]] that provides [[Object-oriented programming|object-oriented programming]] (OOP) features such as [[Class (computer programming)|classes]] and methods.
'''Object Pascal''' is an extension to the programming language [[Pascal (programming language)|Pascal]] that provides [[Object-oriented programming|object-oriented programming]] (OOP) features such as classes and methods.


The language was originally developed by [[Company:Apple Inc.|Apple Computer]] as ''Clascal'' for the [[Engineering:Apple Lisa|Lisa]] Workshop development system. As Lisa gave way to Macintosh, Apple collaborated with [[Biography:Niklaus Wirth|Niklaus 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 the [[Software:MacApp|MacApp]] [[Software:Application framework|application framework]]. The language lost its place as the main development language on the Mac in 1991 with the release of the [[C++]]-based MacApp 3.0. Official support ended in 1996.
The language was originally developed by [[Company:Apple Inc.|Apple Computer]] as ''[[Clascal]]'' for the [[Engineering:Apple Lisa|Lisa]] Workshop development system. As Lisa gave way to Macintosh, Apple collaborated with [[Biography:Niklaus Wirth|Niklaus 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 the [[Software:MacApp|MacApp]] [[Software:Application framework|application framework]]. The language lost its place as the main development language on the Mac in 1991 with the release of the [[C++]]-based MacApp 3.0. Official support ended in 1996.


[[Company:NortonLifeLock|Symantec]] also developed a [[Compiler|compiler]] for Object Pascal for their Think Pascal product, which could compile programs much faster than Apple's own [[Software:Macintosh Programmer's Workshop|Macintosh Programmer's Workshop]] (MPW). Symantec then developed the Think Class Library (TCL), based on MacApp concepts, which could be called from both Object Pascal and [[Software:THINK C|THINK C]]. The Think suite largely displaced MPW as the main development platform on the Mac in the late 1980s.
[[Company:Gen Digital|Symantec]] also developed a [[Compiler|compiler]] for Object Pascal for their Think Pascal product, which could compile programs much faster than Apple's own [[Software:Macintosh Programmer's Workshop|Macintosh Programmer's Workshop]] (MPW). Symantec then developed the Think Class Library (TCL), based on MacApp concepts, which could be called from both Object Pascal and [[THINK 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 PC [[Library (computing)|libraries]] remained mainly based on Pascal.
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 PC [[Library (computing)|libraries]] remained mainly based on Pascal.


[[Company:Borland|Borland]] added support for object-oriented programming to [[Software:Turbo Pascal|Turbo Pascal]] 5.5, which would eventually become the basis for the Object Pascal dialect used in [[Software:Delphi|Delphi]]. 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.
[[Company:Borland|Borland]] added support for object-oriented programming to [[Software:Turbo Pascal|Turbo Pascal]] 5.5, which would eventually become the basis for the Object Pascal dialect used in [[Software:Delphi|Delphi]] created by Anders 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|.NET Framework]] which included Hejlsberg's [[C Sharp (programming language)|C#]].


==History==
==History==
===Apple Pascal===
===Apple Pascal===
Pascal became a major language in the programming world in the 1970s, with high-quality implementations on most [[Minicomputer|minicomputer]] platforms and [[Microcomputer|microcomputer]]s. Among the later was the [[UCSD Pascal]] system, which compiled to an intermediate ''p-System'' code format that could then run on multiple platforms. Apple licensed UCSD and used it as the basis for their [[Software:Apple Pascal|Apple Pascal]] system for the Apple II and Apple III.
Pascal became a major language in the programming world in the 1970s, with high-quality implementations on most [[Minicomputer|minicomputer]] platforms and [[Microcomputer|microcomputer]]s. Among the latter was the [[UCSD Pascal]] system, which compiled to an intermediate ''p-System'' code format that could then run on multiple platforms. Apple licensed UCSD and used it as the basis for their [[Software:Apple Pascal|Apple Pascal]] system for the Apple II and Apple III.


Pascal became one of the major languages in the company in this period. With the start of the [[Engineering:Apple Lisa|Apple Lisa]] project, Pascal was selected as the main programming language of the platform, although this time as a ''compiler'' in contrast to the p-System ''interpreter''.
Pascal became one of the major languages in the company in this period. With the start of the [[Engineering:Apple Lisa|Apple Lisa]] project, Pascal was selected as the main programming language of the platform, although this time as a ''compiler'' in contrast to the p-System ''interpreter''.


===Clascal and Apple's early Object Pascal===
===Clascal and Apple's early Object Pascal===
Object Pascal is an extension of the Pascal language that was developed at [[Company:Apple Inc.|Apple Computer]] by a team led by [[Biography:Larry Tesler|Larry Tesler]] in consultation with [[Biography:Niklaus Wirth|Niklaus Wirth]], the inventor of Pascal.<ref>{{cite journal |last=Tesler |first=Larry |date=1985 |title=Object Pascal Report |journal=Structured Language World |volume=9 |issue=3 |pages=10–7}}</ref> It is descended from an earlier object-oriented version of Pascal named [[Clascal]], which was available on the [[Engineering:Apple Lisa|Lisa]] computer.
Object Pascal is an extension of the Pascal language that was developed at [[Company:Apple Inc.|Apple Computer]] by a team led by [[Biography:Larry Tesler|Larry Tesler]] in consultation with [[Biography:Niklaus Wirth|Niklaus Wirth]], the inventor of Pascal.<ref>{{cite journal |last=Tesler |first=Larry |date=1985 |title=Object Pascal Report |journal=Structured Language World |volume=9 |issue=3 |pages=10–7}}</ref><ref>{{cite web |last=Tesler | first=Larry |title=Object Pascal for the Macintosh |url=https://bitsavers.org/pdf/apple/mac/developer/MacApp/Object_Pascal_For_The_Macintosh_19850214.pdf |date=February 4, 1985 |access-date=March 13, 2025}}</ref> It is descended from an earlier object-oriented version of Pascal named [[Clascal]], which was available on the [[Engineering:Apple Lisa|Lisa]] computer.


Object Pascal was needed to support [[Software:MacApp|MacApp]], an expandable Macintosh application framework that would now be termed a [[Class library|class 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.
Object Pascal was needed to support [[Software:MacApp|MacApp]], an expandable Macintosh application framework that would now be termed a [[Class library|class 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.
Line 59: Line 59:
Apple dropped support for Object Pascal when they moved from [[Motorola 68000 series]] chips to IBM's [[PowerPC]] architecture in 1994. MacApp 3.0, had already been rewritten in [[C++]] and ported to this platform.
Apple dropped support for Object Pascal when they moved from [[Motorola 68000 series]] chips to IBM's [[PowerPC]] architecture in 1994. MacApp 3.0, had already been rewritten in [[C++]] and ported to this platform.


Metrowerks offered with [[Software:CodeWarrior|CodeWarrior]] an Object Pascal compiler for Macintosh that targeted both [[Motorola 68000 series|68k]] and [[PowerPC]], both in their IDE and as MPW tools. Macintosh developers using Object Pascal had a path to port to the [[PowerPC]], even architecture after both Apple and Symantec dropped support. [[Software:MacApp|MacApp]] 2.0, written in Object Pascal, was ported to the PowerPC using [[Software:CodeWarrior|CodeWarrior]].<ref name=mt1995_11>
Metrowerks bundled an Object Pascal compiler with [[Software:CodeWarrior|CodeWarrior]] that targeted both [[Motorola 68000 series|68k]] and [[PowerPC]], both in their IDE and as MPW tools. Macintosh developers using Object Pascal had a path to port to the [[PowerPC]], even after both Apple and Symantec dropped support. [[Software:MacApp|MacApp]] 2.0, written in Object Pascal, was ported to the PowerPC using [[Software:CodeWarrior|CodeWarrior]].<ref name=mt1995_11>
{{cite magazine
{{cite magazine
| magazine = MacTech
| magazine = MacTech
Line 88: Line 88:
In 1986, [[Company:Borland|Borland]] introduced similar extensions, also named Object Pascal, to the [[Software:Turbo Pascal|Turbo Pascal]] product for the Macintosh, and in 1989 for Turbo Pascal 5.5 for DOS. When Borland refocused from [[Engineering:DOS|DOS]] to [[Software:Microsoft Windows|Windows]] in 1994, they created a successor to Turbo Pascal, named [[Software:Delphi|Delphi]], and introduced a new set of extensions to create what is now known as the Delphi language.
In 1986, [[Company:Borland|Borland]] introduced similar extensions, also named Object Pascal, to the [[Software:Turbo Pascal|Turbo Pascal]] product for the Macintosh, and in 1989 for Turbo Pascal 5.5 for DOS. When Borland refocused from [[Engineering:DOS|DOS]] to [[Software:Microsoft Windows|Windows]] in 1994, they created a successor to Turbo Pascal, named [[Software:Delphi|Delphi]], 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 keyword <code>class</code> in preference to <code>object</code>, the Create constructor and a virtual Destroy destructor (and negating having to call the <code>New</code> and <code>Dispose</code> procedures), properties, method pointers, and some other things. These were inspired by the [[Organization:International Organization for Standardization|ISO]] working draft for object-oriented extensions, but many of the differences from Turbo Pascal's dialect (such as the draft's requirement that all methods be [[Virtual function|virtual]]) were ignored.


The Delphi language has continued to evolve over the years to support constructs such as [[Dynamic array|dynamic array]]s, [[Generic programming|generics]] and [[Anonymous function|anonymous methods]]. The old object syntax introduced by Apple ("Old-Style Object Types") is still supported.<ref>{{cite book |last1=Lischner |first1=Ray |title=Delphi in a nutshell: a desktop quick reference |date=2000 |publisher=O'Reilly and Associates |location=Sebastopol, CA |isbn=1565926595 |edition=1st |url-access=registration |url=https://archive.org/details/delphidesktopqui00lisc}}</ref>
The Delphi language has continued to evolve over the years to support constructs such as [[Dynamic array|dynamic array]]s, [[Generic programming|generics]] and [[Anonymous function|anonymous methods]]. The old object syntax introduced by Apple ("Old-Style Object Types") is still supported.<ref>{{cite book |last1=Lischner |first1=Ray |title=Delphi in a nutshell: a desktop quick reference |date=2000 |publisher=O'Reilly and Associates |location=Sebastopol, CA |isbn=1565926595 |edition=1st |url-access=registration |url=https://archive.org/details/delphidesktopqui00lisc}}</ref>


==Versions==
==Versions==
* [[Company:Borland|Borland]] used the name ''Object Pascal'' for the programming language in the first versions, but later renamed it to ''Delphi''. [[Compiler]]s that claim to be compatible with Object Pascal are often trying to be compatible with Delphi [[Source code|source code]].{{Citation needed|date=August 2009}} Because Delphi is a [[Social:Trademark|trademark]], compatible compilers continue using the name ''Object Pascal''.
* [[Company:Borland|Borland]] used the name ''Object Pascal'' for the programming language in the first versions, but later renamed it to ''Delphi''. [[Compiler]]s that claim to be compatible with Object Pascal are often trying to be compatible with Delphi [[Source code|source code]]. Because Delphi is a [[Social:Trademark|trademark]], compatible compilers continue using the name ''Object Pascal''.
* [[Company:Embarcadero Technologies|Embarcadero Technologies]], which purchased Delphi in 2008,<ref>[http://edn.embarcadero.com/article/38132 Community Letter: Embarcadero Technologies agrees to acquire CodeGear from Borland]. Edn.embarcadero.com. Retrieved on 2013-07-21.</ref> sells the [[Software:Delphi|Delphi]] [[Integrated development environment|integrated development environment]] (IDE) that compiles the Delphi dialect of Object Pascal to [[Software:Windows|Windows]] and [[Software:MacOS|macOS]], [[Software:IOS|iOS]], [[Software:Android (operating system)|Android]] and Web.
* [[Company:Embarcadero Technologies|Embarcadero Technologies]], which purchased Delphi in 2008,<ref>[http://edn.embarcadero.com/article/38132 Community Letter: Embarcadero Technologies agrees to acquire CodeGear from Borland] {{Webarchive|url=https://web.archive.org/web/20180302044728/http://edn.embarcadero.com/article/38132 |date=2018-03-02 }}. Edn.embarcadero.com. Retrieved on 2013-07-21.</ref> sells the [[Software:Delphi|Delphi]] [[Integrated development environment|integrated development environment]] (IDE) that compiles the Delphi dialect of Object Pascal to [[Software:Windows|Windows]] and [[Software:MacOS|macOS]], [[Software:IOS|iOS]], [[Software:Android (operating system)|Android]] and Web.
* .NET support existed from Delphi 8 through Delphi 2005, 2006, and 2007, which now has been replaced by another language, ''Oxygene'' (see below), which is not fully backward-compatible.
* [[.NET Framework|.NET]] support existed from Delphi 8 through Delphi 2005, 2006, and 2007, which now has been replaced by another language, ''Oxygene'' (see below), which is not fully backward-compatible.
* The [[Oxygene (programming language)|Oxygene]] language developed by RemObjects Software targets the [[Common Language Infrastructure]], the [[Software:Java (software platform)|Java]] Runtime Environment and [[Company:Apple Inc.|Apple]]'s Cocoa frameworks for [[Software:IOS|iOS]] and [[Software:MacOS|macOS]].
* The [[Oxygene (programming language)|Oxygene]] language developed by [[Company:RemObjects Software|RemObjects Software]] targets the [[Common Language Infrastructure]], the [[Software:Java (software platform)|Java]] Runtime Environment and [[Company:Apple Inc.|Apple]]'s Cocoa frameworks for [[Software:IOS|iOS]] and [[Software:MacOS|macOS]].
* The [[Open source|open source]] [[Software:Free Pascal|Free Pascal]] project allows the language to be compiled for a wide range of [[Operating system|operating system]]s, including [[Software:Linux|Linux]] ([[32-bit|32-bit]], 64-bit), [[Software:FreeBSD|FreeBSD]], [[Software:Classic Mac OS|Classic Mac OS]], [[Software:MacOS|macOS]], [[Software:Solaris (operating system)|Solaris]], [[Software:Windows API|Windows API]] (32, 64, [[Software:Windows CE|CE]]), the [[ARM architecture family|ARM]] [[Instruction set architecture|instruction set architecture]] (ISA), and several other hardware architectures. The first version of Free Pascal for the [[Engineering:IPhone|iPhone]] [[Software development kit|software development kit]] (SDK) 2.''x'' was announced on January 17, 2009.<ref name="fpciphone">{{cite web |title=iPhone/iPod development |publisher=Free Pascal development team |url=http://wiki.freepascal.org/iPhone/iPod_development |access-date=2009-04-13}}</ref>
* The [[Open source|open source]] [[Software:Free Pascal|Free Pascal]] project allows the language to be compiled for a wide range of [[Operating system|operating system]]s, including [[Software:Linux|Linux]] ([[32-bit|32-bit]], 64-bit), [[Software:FreeBSD|FreeBSD]], [[Software:Classic Mac OS|Classic Mac OS]], [[Software:MacOS|macOS]], [[Software:Solaris (operating system)|Solaris]], [[Software:Windows API|Windows API]] (32, 64, [[Software:Windows CE|CE]]), the [[ARM architecture family|ARM]] [[Instruction set architecture|instruction set architecture]] (ISA), and several other hardware architectures. The first version of Free Pascal for the [[Engineering:IPhone|iPhone]] [[Software development kit|software development kit]] (SDK) 2.''x'' was announced on January 17, 2009.<ref name="fpciphone">{{cite web |title=iPhone/iPod development |publisher=Free Pascal development team |url=http://wiki.freepascal.org/iPhone/iPod_development |access-date=2009-04-13 |archive-date=2009-04-28 |archive-url=https://web.archive.org/web/20090428024653/http://wiki.freepascal.org/iPhone/iPod_development |url-status=live }}</ref>
* The [[Smart Pascal]] language<ref name="asmartbook">{{cite book|title=A Smart Book|date=18 May 2012|publisher=Leanpub|url=https://leanpub.com/asmartbook}}</ref> targets [[ECMAScript]]–[[JavaScript]] and is used in Smart Mobile Studio, written by Jon Lennart Aasenden and published by Optimale Systemer (2012). The language greatly simplifies [[HTML5]] development through object-oriented, and [[Rapid application development|rapid application development]] (RAD) methods. Smart Pascal integrates tightly with established technologies such as [[Software:Node.js|node.js]], Embarcadero DataSnap, and Remobjects SDK to produce high-performance [[Client–server model|client–server model]] web applications. The language allows easy creation of visual components and reusable libraries. The Smart Pascal dialect stems from the DWScript language, extended to better integrate with the JavaScript environment and libraries, such as <code>asm</code> sections which are plain JavaScript but have access to Pascal symbols, or ''external'' classes which map directly to prototypal JavaScript classes. Smart Pascal introduces true inheritance, classes, partial classes, interfaces, a virtual method table and many other advanced constructs which are not a part of JavaScript by default.
* The [[Smart Pascal]] language<ref name="asmartbook">{{cite book|title=A Smart Book|date=18 May 2012|publisher=Leanpub|url=https://leanpub.com/asmartbook|access-date=19 June 2013|archive-date=25 May 2013|archive-url=https://web.archive.org/web/20130525145612/https://leanpub.com/asmartbook|url-status=live}}</ref> targets [[ECMAScript]]–[[JavaScript]] and is used in Smart Mobile Studio, written by Jon Lennart Aasenden and published by Optimale Systemer (2012). The language greatly simplifies [[HTML5]] development through object-oriented, and [[Rapid application development|rapid application development]] (RAD) methods. Smart Pascal integrates tightly with established technologies such as [[Software:Node.js|node.js]], Embarcadero DataSnap, and Remobjects SDK to produce high-performance [[Client–server model|client–server model]] web applications. The language allows easy creation of visual components and reusable libraries. The Smart Pascal dialect stems from the DWScript language, extended to better integrate with the JavaScript environment and libraries, such as <code>asm</code> sections which are plain JavaScript but have access to Pascal symbols, or ''external'' classes which map directly to prototypal JavaScript classes. Smart Pascal introduces true inheritance, classes, partial classes, interfaces, a virtual method table and many other advanced constructs which are not a part of JavaScript by default.
* [[Software:MIDletPascal|MIDletPascal]] runs on a [[Java virtual machine]] (JVM) [[Software:Bytecode|bytecode]] platform; which Free Pascal also targets, with far more features.
* The [[Company:Morfik|Morfik]] Pascal language, developed by Morfik, targets [[Ajax (programming)|Ajax]]-enabled Web applications. The compiler is built into the company's AppsBuilder IDE and allows Object Pascal code to be used in implementing code to execute in a browser or server. It uses the [[Software:Free Pascal|Free Pascal]] compiler to generate native binaries from Object Pascal.
* The [[Company:Morfik|Morfik]] Pascal language, developed by Morfik, targets [[Ajax (programming)|Ajax]]-enabled Web applications. The compiler is built into the company's AppsBuilder IDE and allows Object Pascal code to be used in implementing code to execute in a browser or server. It uses the [[Software:Free Pascal|Free Pascal]] compiler to generate native binaries from Object Pascal.
* The open source [[Software:GNU Pascal|GNU Pascal]] compiler is available as a front-end to the [[Software:GNU Compiler Collection|GNU Compiler Collection]], which implements the [[Organization:International Organization for Standardization|International Organization for Standardization]] (ISO) 7185 Pascal standard, and most of the ISO 10206 Extended Pascal standard.
* The open source [[Software:GNU Pascal|GNU Pascal]] compiler is available as a front-end to the [[Software:GNU Compiler Collection|GNU Compiler Collection]], which implements the [[Organization:International Organization for Standardization|International Organization for Standardization]] (ISO) 7185 Pascal standard, and most of the ISO 10206 Extended Pascal standard.
* Turbo51 is a free compiler to program [[Engineering:Intel 8051|Intel 8051]] chips.<ref>{{cite web |url=http://turbo51.com/ |title=Turbo51: Turbo Pascal Compiler for 8051 microcontrollers |last=Funa |first=Igor |date=2021 |url-status=live |archive-url=https://web.archive.org/web/20180925023509/http://turbo51.com/ |archive-date=2018-09-25}}</ref>
* Turbo51 is a free compiler to program [[Engineering:Intel 8051|Intel 8051]] chips.<ref>{{cite web |url=http://turbo51.com/ |title=Turbo51: Turbo Pascal Compiler for 8051 microcontrollers |last=Funa |first=Igor |date=2021 |url-status=live |archive-url=https://web.archive.org/web/20180925023509/http://turbo51.com/ |archive-date=2018-09-25}}</ref>
* WDSibyl is an open source Delphi-like IDE and compiler available for [[Software:Microsoft Windows|Microsoft Windows]] and OS/2,<ref>{{cite web |url=https://www.wdsibyl.org/ |title=WDSibyl: Visual Development Environment |last=Draxler |first=Wolfgang |url-status=dead |archive-url=https://web.archive.org/web/20200212174135/https://www.wdsibyl.org/ |archive-date=2020-02-12}}</ref> and is a commercial [[Software:Turbo Pascal|Turbo Pascal]] compatible environment released by a company named Speedsoft that was later developed into a Delphi-like RAD environment named Sybil, and then open sourced under the GPL when that company closed down. Wolfgang Draxler (WD) now maintains the software. The compiler used seems to be located in a DLL and is not open-source.
* WDSibyl is an open source Delphi-like IDE and compiler available for [[Software:Microsoft Windows|Microsoft Windows]] and OS/2,<ref>{{cite web |url=https://www.wdsibyl.org/ |title=WDSibyl: Visual Development Environment |last=Draxler |first=Wolfgang |url-status=live |archive-url=https://web.archive.org/web/20200212174135/https://www.wdsibyl.org/ |archive-date=2020-02-12}}</ref> and is a commercial [[Software:Turbo Pascal|Turbo Pascal]] compatible environment released by a company named Speedsoft that was later developed into a Delphi-like RAD environment named Sybil, and then open sourced under the GPL when that company closed down. Wolfgang Draxler (WD) now maintains the software.<ref>
{{cite web
|url= http://www.edm2.com/index.php/WDSibyl
|title= EDM/2: WDSibyl
|archive-url= https://web.archive.org/web/20210324031505/http://www.edm2.com/index.php/WDSibyl
|archive-date= 2021-03-24
}}
</ref><ref>
{{cite web
|url= http://www.edm2.com/index.php/List_of_Tools
|title= EDM/2: List of Tools
|archive-url= https://web.archive.org/web/20220821090646/http://www.edm2.com/index.php/List_of_Tools
|archive-date= 2022-08-21
}}
</ref><ref>
{{cite web
|url=https://ecsoft2.org/wdsibyl
|title= eCSoft/2: The Complete OS/2 Software Encyclopedia: WDSibyl
|archive-date= 2021-10-17
|archive-url=https://web.archive.org/web/20211017225456/https://ecsoft2.org/wdsibyl
}}


==Compilers==
==Compilers==
Object Pascal [[Compiler|compiler]]s are available for a wide range of [[Operating system|operating system]]s and architectures.
Object Pascal [[Compiler|compiler]]s are available for a wide range of [[Operating system|operating system]]s and architectures.


* [[Software:Delphi|Delphi]] is probably the best known compiler. It is the successor of the highly successful Borland Pascal and [[Software:Turbo Pascal|Turbo Pascal]] product line. It targets [[Software:Windows 9x|Windows 9x]] (Delphi 2007 and older), the [[Software:Windows NT|Windows NT]] family, .NET Framework (Delphi 8, 2005, 2007), [[Software:MacOS|macOS]] (Delphi XE2 and later), [[Software:IOS|iOS]] (Delphi XE2 and later, generating native binaries in XE4 and later), [[Software:Android (operating system)|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).
* [[Software:Delphi|Delphi]] is probably the best known compiler. It is the successor of the highly successful Borland Pascal and [[Software:Turbo Pascal|Turbo Pascal]] product line. It targets [[Software:Windows 9x|Windows 9x]] (Delphi 2007 and older), the [[Software:Windows NT|Windows NT]] family, [[.NET Framework|.NET Framework]] (Delphi 8, 2005, 2007), [[Software:MacOS|macOS]] (Delphi XE2 and later), [[Software:IOS|iOS]] (Delphi XE2 and later, generating native binaries in XE4 and later), [[Software:Android (operating system)|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).
* [[Software:Free Pascal|Free Pascal]] Compiler (FPC) is an open-source Object Pascal compiler that supports many Pascal dialects, including [[Software:Turbo Pascal|Turbo Pascal]] 7, Delphi, and others. Currently, FPC can generate code for [[IA-32]], [[X86-64|x86-64]], [[PowerPC]], [[SPARC]], and [[ARM architecture|ARM]] processors, and for several operating systems, including [[Software:Microsoft Windows|Microsoft Windows]], [[Software:Linux|Linux]], [[Software:FreeBSD|FreeBSD]], [[Software:Classic Mac OS|Classic Mac OS]], and [[Software:MacOS|macOS]] (with an [[Software:Xcode|Xcode]] integration kit). Several separate projects exist to facilitate rapid application development with FPC, the most prominent one being [[Software:Lazarus (IDE)|Lazarus (IDE)]].
* [[Software:Free Pascal|Free Pascal]] Compiler (FPC) is an open-source Object Pascal compiler that supports many Pascal dialects, including [[Software:Turbo Pascal|Turbo Pascal]] 7, Delphi, and others. Currently, FPC can generate code for [[IA-32]], [[X86-64|x86-64]], [[PowerPC]], [[SPARC]], and [[ARM architecture|ARM]] processors, and for several operating systems, including [[Software:Microsoft Windows|Microsoft Windows]], [[Software:Linux|Linux]], [[Software:FreeBSD|FreeBSD]], [[Software:Classic Mac OS|Classic Mac OS]], and [[Software:MacOS|macOS]] (with an [[Software:Xcode|Xcode]] integration kit). Several separate projects exist to facilitate rapid application development with FPC, the most prominent one being [[Software:Lazarus (IDE)|Lazarus (IDE)]].
* [[Software:GNU Pascal|GNU Pascal]] (a separately distributed part of the [[Software:GNU Compiler Collection|GNU 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.
* [[Software:GNU Pascal|GNU Pascal]] (a separately distributed part of the [[Software:GNU Compiler Collection|GNU 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 (programming language)|Oxygene]] (formerly ''Chrome'') is an Object Pascal compiler from RemObjects Software that integrates into [[Software:Microsoft Visual Studio|Microsoft Visual Studio]]. It is also available as free [[Command-line interface|command-line interface]] compiler that runs native on [[Common Language Infrastructure|CLI]]. It is three compilers in one, each targeting a different platform: Echoes for .NET Framework, [[Software:Mono|Mono]], [[Software:Windows Runtime|WinRT]] and [[Software:Windows Phone 8|Windows Phone 8]], Cooper for JDK and [[Software:Android (operating system)|Android]], and Nougat for [[Software:IOS|iOS]] and [[Software:MacOS|macOS]].
* [[Oxygene (programming language)|Oxygene]] (formerly ''Chrome'') is an Object Pascal compiler from [[Company:RemObjects Software|RemObjects Software]] that integrates into [[Software:Microsoft Visual Studio|Microsoft Visual Studio]]. It is also available as free [[Command-line interface|command-line interface]] compiler that runs native on [[Common Language Infrastructure|CLI]]. It is three compilers in one, each targeting a different platform: Echoes for [[.NET Framework|.NET Framework]], [[Software:Mono|Mono]], [[Software:Windows Runtime|WinRT]] and [[Software:Windows Phone 8|Windows Phone 8]], Cooper for JDK and [[Software:Android (operating system)|Android]], and Nougat for [[Software:IOS|iOS]] and [[Software:MacOS|macOS]].
* [[Software:MIDletPascal|MIDletPascal]] is a mobile application development tool that generates Java ME bytecode.
* [[PocketStudio]] is a Pascal-based [[Integrated development environment|integrated development environment]] (IDE) for [[Software:Palm OS|Palm OS]].
* Smart Mobile Studio is a [[Source-to-source compiler|source-to-source compiler]] that transforms Pascal [[Source code|source code]] to [[JavaScript]]
* Ultibo.org Core is based on Free Pascal, with development in the Lazarus IDE for embedded [[Engineering:Raspberry Pi|Raspberry Pi]] applications.


===Legacy products===
===Legacy products===
Line 123: Line 137:
==Interpreters==
==Interpreters==
{{Main|Pascal Script}}
{{Main|Pascal Script}}
[http://www.remobjects.com/ps Pascal Script] (formerly ''InnerFuse'') and [http://code.google.com/p/dwscript/ DWScript] (Delphi Web Script) are open-source Object Pascal [[Interpreter (computing)|interpreters]] 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 supports [[Just-in-time compilation|just-in-time compilation]] (JIT). Modern Pascal provides 3 different interpreters: a [[Command-line interface|command-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's [[Source code|source code]].<ref>{{cite web |url=http://www.modernpascal.com/ |title=Modern Pascal}}</ref>
[http://www.remobjects.com/ps Pascal Script] (formerly ''InnerFuse'') and [http://code.google.com/p/dwscript/ DWScript] (Delphi Web Script) are open-source Object Pascal [[Interpreter (computing)|interpreters]] 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 supports [[Just-in-time compilation|just-in-time compilation]] (JIT). Modern Pascal provides 3 different interpreters: a [[Command-line interface|command-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's [[Source code|source code]].<ref>{{cite web |url=http://www.modernpascal.com/ |title=Modern Pascal |access-date=2018-10-22 |archive-date=2018-12-11 |archive-url=https://web.archive.org/web/20181211010242/http://modernpascal.com/ |url-status=live }}</ref>


==Sample "Hello World" programs==
==Sample "Hello World" programs==
Line 129: Line 143:


===Apple version===
===Apple version===
<source lang="objectpascal">
<syntaxhighlight lang="objectpascal">
program ObjectPascalExample;
program ObjectPascalExample;


Line 150: Line 164:
   Dispose(HelloWorld);
   Dispose(HelloWorld);
end.
end.
</source>
</syntaxhighlight>


===Turbo Pascal version===
===Turbo Pascal version===
Line 156: Line 170:


====Stack based allocation====
====Stack based allocation====
<source lang="objectpascal">
<syntaxhighlight lang="objectpascal">
program ObjectPascalExample;
program ObjectPascalExample;


Line 174: Line 188:
   HelloWorld.Put;
   HelloWorld.Put;
end.
end.
</source>
</syntaxhighlight>


====Heap based allocation====
====Heap based allocation====
<source lang="objectpascal">
<syntaxhighlight lang="objectpascal">
program ObjectPascalExample;
program ObjectPascalExample;


Line 199: Line 213:
   Dispose(HelloWorld);
   Dispose(HelloWorld);
end.
end.
</source>
</syntaxhighlight>


Another example:
Another example:


<source lang="objectpascal">
<syntaxhighlight lang="objectpascal">
program ObjectPascalExample;
program ObjectPascalExample;


Line 235: Line 249:
   Dispose(HelloWorld3); { so it must release only two instances }
   Dispose(HelloWorld3); { so it must release only two instances }
end.
end.
</source>
</syntaxhighlight>


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


===Delphi and Free Pascal version===
===Delphi and Free Pascal version===
<source lang="delphi">
<syntaxhighlight lang="delphi">
program ObjectPascalExample;
program ObjectPascalExample;


Line 261: Line 275:
   HelloWorld.Free;                      { this line deallocates the THelloWorld object pointed to by HelloWorld }
   HelloWorld.Free;                      { this line deallocates the THelloWorld object pointed to by HelloWorld }
end.
end.
</source>
</syntaxhighlight>
Note that the object construct is still available in Delphi and Free Pascal.
Note that the object construct is still available in Delphi and Free Pascal.


===Oxygene version===
===Oxygene version===
<source lang="objectpascal">
<syntaxhighlight lang="objectpascal">
namespace ObjectPascalExample;
namespace ObjectPascalExample;


Line 293: Line 307:


end.
end.
</source>
</syntaxhighlight>


===DWScript (Smart Pascal) version===
===DWScript (Smart Pascal) version===
<source lang="objectpascal">
<syntaxhighlight lang="objectpascal">
type
type
   THelloWorld = class
   THelloWorld = class
Line 307: Line 321:
var HelloWorld := THelloWorld.Create;
var HelloWorld := THelloWorld.Create;
HelloWorld.Put;
HelloWorld.Put;
</source>
</syntaxhighlight>


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


==Development==
==Development==
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) support [[Operator overloading|operator overloading]]. Delphi has also introduced many other features since version 7,<ref name="newftrs">{{cite web|title=New Delphi language features since Delphi 7|publisher=CodeGear|url=http://dn.codegear.com/article/34324|access-date=2008-07-06}}</ref> 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.
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) support [[Operator overloading|operator overloading]]. Delphi has also introduced many other features since version 7,<ref name="newftrs">{{cite web|title=New Delphi language features since Delphi 7|publisher=CodeGear|url=http://dn.codegear.com/article/34324|access-date=2008-07-06|archive-date=2008-07-02|archive-url=https://web.archive.org/web/20080702184859/http://dn.codegear.com/article/34324|url-status=live}}</ref> 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==
==References==

Latest revision as of 14:41, 24 May 2026

Short description: Branch of object-oriented derivatives of Pascal programming language
Object Pascal
ParadigmsImperative, structured, object-oriented, functional (Delphi dialect only), component-based, event-driven, generic
FamilyWirth Pascal
DevelopersApple Computer (initial)
Borland International[1]
First appeared1986; 40 years ago (1986)
Typing disciplineStatic and dynamic (dynamic typing through variants, array of const, and RTTI), strong, safe
ScopeLexical (static)
PlatformARM, x86, PowerPC, ppc64, SPARC, MIPS, CLI, Java
Filename extensions.p, .pp, .pas
Major implementations
Delphi (x86, ARM), Free Pascal (x86, PowerPC, ppc64, SPARC, MIPS, ARM), Oxygene (CLI, Java, Native Cocoa), Smart Mobile Studio (JavaScript)
Dialects
Apple, Turbo Pascal, Free Pascal (using objfpc or delphi mode), Delphi, Delphi.NET, Delphi Web Script, PascalABC.NET, Oxygene
Influenced by
Pascal, Simula, Smalltalk
Influenced
C#, Genie, Java, Nim, C/AL

Object Pascal is an extension to the programming language Pascal that provides object-oriented programming (OOP) features such as classes and methods.

The language was originally developed by Apple Computer as Clascal for the Lisa Workshop development system. As Lisa gave way to Macintosh, Apple collaborated with Niklaus 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 the MacApp application framework. The language lost its place as the main development language on the Mac in 1991 with the release of the C++-based MacApp 3.0. Official support ended in 1996.

Symantec also developed a compiler for Object Pascal for their Think Pascal product, which could compile programs much faster than Apple's own Macintosh Programmer's Workshop (MPW). Symantec then developed the Think Class Library (TCL), based on MacApp concepts, which could be called from both Object Pascal and THINK 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 PC libraries remained mainly based on Pascal.

Borland added support for object-oriented programming to Turbo Pascal 5.5, which would eventually become the basis for the Object Pascal dialect used in Delphi created by Anders 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's C#.

History

Apple Pascal

Pascal became a major language in the programming world in the 1970s, with high-quality implementations on most minicomputer platforms and microcomputers. Among the latter was the UCSD Pascal system, which compiled to an intermediate p-System code format that could then run on multiple platforms. Apple licensed UCSD and used it as the basis for their Apple Pascal system for the Apple II and Apple III.

Pascal became one of the major languages in the company in this period. With the start of the Apple Lisa project, Pascal was selected as the main programming language of the platform, although this time as a compiler in contrast to the p-System interpreter.

Clascal and Apple's early Object Pascal

Object Pascal is an extension of the Pascal language that was developed at Apple Computer by a team led by Larry Tesler in consultation with Niklaus Wirth, the inventor of Pascal.[2][3] It is descended from an earlier object-oriented version of Pascal named Clascal, which was available on the Lisa computer.

Object Pascal was needed to support MacApp, an expandable Macintosh application framework that would now be termed a class 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 Pascal integrated development environment (IDE). The IDE includes the compiler and an editor with syntax highlighting and checking, a powerful debugger, 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 from Motorola 68000 series chips to IBM's PowerPC architecture in 1994. MacApp 3.0, had already been rewritten in C++ and ported to this platform.

Metrowerks bundled an Object Pascal compiler with CodeWarrior that targeted both 68k and PowerPC, both in their IDE and as MPW tools. Macintosh developers using Object Pascal had a path to port to the PowerPC, even after both Apple and Symantec dropped support. MacApp 2.0, written in Object Pascal, was ported to the PowerPC using CodeWarrior.[5][6]

Borland, Inprise, CodeGear, and Embarcadero years

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


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

Versions

  • Borland used the name Object Pascal for the programming language in the first versions, but later renamed it to Delphi. Compilers that claim to be compatible with Object Pascal are often trying to be compatible with Delphi source code. Because Delphi is a trademark, compatible compilers continue using the name Object Pascal.
  • Embarcadero Technologies, which purchased Delphi in 2008,[8] sells the Delphi integrated development environment (IDE) that compiles the Delphi dialect of Object Pascal to Windows and macOS, iOS, Android and Web.
  • .NET support existed from Delphi 8 through Delphi 2005, 2006, and 2007, which now has been replaced by another language, Oxygene (see below), which is not fully backward-compatible.
  • The Oxygene language developed by RemObjects Software targets the Common Language Infrastructure, the Java Runtime Environment and Apple's Cocoa frameworks for iOS and macOS.
  • The open source Free Pascal project allows the language to be compiled for a wide range of operating systems, including Linux (32-bit, 64-bit), FreeBSD, Classic Mac OS, macOS, Solaris, Windows API (32, 64, CE), the ARM instruction set architecture (ISA), and several other hardware architectures. The first version of Free Pascal for the iPhone software development kit (SDK) 2.x was announced on January 17, 2009.[9]
  • The Smart Pascal language[10] targets ECMAScriptJavaScript and is used in Smart Mobile Studio, written by Jon Lennart Aasenden and published by Optimale Systemer (2012). The language greatly simplifies HTML5 development through object-oriented, and rapid application development (RAD) methods. Smart Pascal integrates tightly with established technologies such as node.js, Embarcadero DataSnap, and Remobjects SDK to produce high-performance client–server model web applications. The language allows easy creation of visual components and reusable libraries. The Smart Pascal dialect stems from the DWScript language, extended to better integrate with the JavaScript environment and libraries, such as asm sections which are plain JavaScript but have access to Pascal symbols, or external classes which map directly to prototypal JavaScript classes. Smart Pascal introduces true inheritance, classes, partial classes, interfaces, a virtual method table and many other advanced constructs which are not a part of JavaScript by default.
  • The Morfik Pascal language, developed by Morfik, targets Ajax-enabled Web applications. The compiler is built into the company's AppsBuilder IDE and allows Object Pascal code to be used in implementing code to execute in a browser or server. It uses the Free Pascal compiler to generate native binaries from Object Pascal.
  • The open source GNU Pascal compiler is available as a front-end to the GNU Compiler Collection, which implements the International Organization for Standardization (ISO) 7185 Pascal standard, and most of the ISO 10206 Extended Pascal standard.
  • Turbo51 is a free compiler to program Intel 8051 chips.[11]
  • WDSibyl is an open source Delphi-like IDE and compiler available for Microsoft Windows and OS/2,[12] and is a commercial Turbo Pascal compatible environment released by a company named Speedsoft that was later developed into a Delphi-like RAD environment named Sybil, and then open sourced under the GPL when that company closed down. Wolfgang Draxler (WD) now maintains the software.[13][14]Cite error: Closing </ref> missing for <ref> tag

Sample "Hello World" programs

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

Apple version

program ObjectPascalExample;

   type
      THelloWorld = object
         procedure Put;
      end;

   var
      HelloWorld: THelloWorld;

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

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

Turbo Pascal version

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

program ObjectPascalExample;

   type
      THelloWorld = object
         procedure Put;
      end;

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

var
  HelloWorld: THelloWorld; { allocated on the stack and can be used without explicit allocation. }
begin
   HelloWorld.Put;
end.

Heap based allocation

program ObjectPascalExample;

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

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

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

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

Another example:

program ObjectPascalExample;

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

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

var
  HelloWorld: 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

program ObjectPascalExample;

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 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

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.

DWScript (Smart Pascal) version

type
   THelloWorld = class
      procedure Put;
      begin
         PrintLn('Hello, World!');
      end
   end;

var HelloWorld := THelloWorld.Create;
HelloWorld.Put;

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

Development

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) support operator overloading. Delphi has also introduced many other features since version 7,[15] 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

  1. Cite error: Invalid <ref> tag; no text was provided for refs named InfoworldTechTalk
  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". https://bitsavers.org/pdf/apple/mac/developer/MacApp/Object_Pascal_For_The_Macintosh_19850214.pdf. 
  4. Seiter, Charles (November 1990). "Think Pascal 3". Macworld 7 (11): 236. https://archive.org/details/mac_MacWorld_9011_November_1990/page/n251/mode/1up. 
  5. Arnold, Brian; McCarthy, Guy (November 1995). "MacApp Pascal Rides again". MacTech 11 (11): 30–31. https://archive.org/details/eu_MacTech-1995-11/page/n31/mode/1up. 
  6. Arnold, Brian (February 1996). "MacApp 2 for PowerPC in Object Pascal". MacTech 12 (2): 25–32. https://archive.org/details/eu_MacTech-1996-02_OCR/page/n26/mode/1up. 
  7. Lischner, Ray (2000). Delphi in a nutshell: a desktop quick reference (1st ed.). Sebastopol, CA: O'Reilly and Associates. ISBN 1565926595. https://archive.org/details/delphidesktopqui00lisc. 
  8. Community Letter: Embarcadero Technologies agrees to acquire CodeGear from Borland . Edn.embarcadero.com. Retrieved on 2013-07-21.
  9. "iPhone/iPod development". Free Pascal development team. http://wiki.freepascal.org/iPhone/iPod_development. 
  10. A Smart Book. Leanpub. 18 May 2012. https://leanpub.com/asmartbook. Retrieved 19 June 2013. 
  11. Funa, Igor (2021). "Turbo51: Turbo Pascal Compiler for 8051 microcontrollers". http://turbo51.com/. 
  12. Draxler, Wolfgang. "WDSibyl: Visual Development Environment". https://www.wdsibyl.org/. 
  13. "EDM/2: WDSibyl". http://www.edm2.com/index.php/WDSibyl. 
  14. "EDM/2: List of Tools". http://www.edm2.com/index.php/List_of_Tools. 
  15. "New Delphi language features since Delphi 7". CodeGear. http://dn.codegear.com/article/34324. 

Delphi