Content deleted Content added
|
|
</syntaxhighlight>
Note that the object construct is still available in Delphi and Free Pascal.
===Modern Pascal version===
<syntaxhighlight lang="delphi">
program ObjectPascalExample;
type
THelloWorld = class
Put:procedure of object;
end;
procedure THelloWorld.Put;
begin
Writeln('Hello, World!');
end;
procedure THelloWorld.Free;
begin
// dispose any pointers //
end;
procedure THelloWorld.Init;
begin
// initialize variables
// link methods (manual RTTI)
with Self do begin
TMethod(@Put):=[@THelloWorld.Put, @Self];
TMethod(@Free):=[@THelloWorld.Free, @Self];
End;
end;
var
HelloWorld: THelloWorld; { this is an implicit pointer }
begin
HelloWorld.Init; { self initialization (pointer to an object) of type THelloWorld }
HelloWorld.Put;
HelloWorld.Free; { this line deallocates the THelloWorld object pointed to by HelloWorld }
end.
</syntaxhighlight>
===Oxygene version===
|