Pointer arithmetics (was: BPCOMPAT v1.10 -released!)
Thu, 23 Oct 1997 11:18:34 +0200 (MEST)
According to Frank Heckenbach:
> Until a (more optimized) version
> of them will be built in, here are some replacements (a bit slower, but
> should be portable and generate no warnings): [...]
Pointer arithmetics is portable and can be used here to speed it up:
Procedure FillChar ( Var Dest: Void; Count: Integer; C: Char );
Var
DestArray: tCharArray absolute Dest;
z: ^Char;
begin (* FillChar *)
for z:= @DestArray [ 0 ] to @DestArray [ Count - 1 ] do
z^:= C;
end (* FillChar *);
(Similar for `move'.)
BTW, pointer arithmetics ... should GPC allow constructions like
(*$X+*)
Var
p, q: ^Char;
p:= q + 42;
or only
p:= succ ( q, 42 ); ?
Personally, I would prefer to allow only the second (Pointer being an
ordinal type) and to consider the first (Pointer + Integer) an error,
but it's technically easier to allow both, so I ask before I remove a
bug somebody might consider a feature. ;-)
Greetings,
Peter
Dipl.-Phys. Peter Gerwinski, Essen, Germany, free physicist and programmer
peter.gerwinski@uni-essen.de - http://home.pages.de/~peter.gerwinski/ [971005]
maintainer GNU Pascal [971001] - http://home.pages.de/~gnu-pascal/ [971005]
Peter Gerwinski (peter@agnes.dida.physik.uni-essen.de)
HTML conversion by Lluís de Yzaguirre i Maura
Institut de Lingüística Aplicada -
Universitat "Pompeu Fabra"
e-mail: de_yza@upf.es