Portability questions (Arrays)_(re)
Mon, 2 Jun 1997 14:21:19 +0200
Peter Gerwinski wrote:
> > function f(var a:t):integer;
> > var
> > p:^integer;
> > begin
> > p:=@a[0];
> > {some loop}
> > if {...} then
> > begin
> > p^:=...;
> > inc(p) {is this ok, BTW?}
> > end;
> > {...}
> > f:="offset of p in a"
> > end.
>
> "inc(p)" should work in GPC. You can even do
>
> for p:= @a [ 0 ] to @a [ n ] do
> p^:= ...;
The latter doesn't fit into the procedure above, but if "inc(p)" works, fine!
> What about intoducing a "difference between pointers" operator which returns
> the number of elements they lie apart (as an integer)?
>
> f:= p - @a [ 0 ];
This would be great!
> (Only with (*$X+*), of course.)
Of course!
--
Frank Heckenbach, Erlangen, Germany
heckenb@mi.uni-erlangen.de
Turbo Pascal: http://www.mi.uni-erlangen.de/~heckenb/programs.htm
Internet links: http://www.mi.uni-erlangen.de/~heckenb/links.htm
Frank Heckenbach (heckenb@mi.uni-erlangen.de)
HTML conversion by Lluís de Yzaguirre i Maura
Institut de Lingüística Aplicada -
Universitat "Pompeu Fabra"
e-mail: de_yza@upf.es