Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 7387c8f97b
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

View file

@ -0,0 +1,42 @@
program pointerDemo;
type
{
A new pointer data type is declared by `` followed by a data type name,
the domain.
The domain data type may not have been declared yet, but must be
declared within the current `type` section.
Most compilers do not support the reference token `` as specified in
the ISO standards 7185 and 10206, but use the alternative `^` (caret).
}
integerReference = ^integer;
var
integerLocation: integerReference;
begin
{
The procedure `new` taken one pointer variable and allocates memory for
one new instance of the pointer domains data type (here an `integer`).
The pointer variable will hold the address of the allocated instance.
}
new(integerLocation);
{
Dereferencing a pointer is done via appending `` to the variables
name. All operations on the domain type are now possible.
}
integerLocation^ := 42;
{
The procedure `dispose` takes one pointer variable and releases the
underlying memory. The supplied variable is otherwise not modified.
}
dispose(integerLocation);
{
In Pascal, `dispose` is not necessary. Any excess memory is automatically
released after `program` termination.
}
end.

View file

@ -0,0 +1,17 @@
program variantRecordDemo;
type
fooReference = ^foo;
foo = record
case Boolean of
false: ( );
true: (location: fooReference);
end;
var
head: fooReference;
begin
new(head, true);
{ … }
dispose(head, true);
end.

View file

@ -0,0 +1,15 @@
program routineParameterDemo(output);
procedure foo(function f: Boolean);
begin
writeLn(f);
end;
function bar: Boolean;
begin
bar := false
end;
begin
foo(bar);
end.