>
> Are const parameters supposed to ensure read only access?
> If so how come one can write to a typed pointer?
>
> program project1;
>
> {$mode objfpc}{$H+}
>
> type
> PSomeRec = ^TSomeRec;
> TSomeRec = record
> a: string;
> b: string;
> end;
>
> procedure ChangeRec1(const Rec: PSomeRec);
> begin
> Rec^.a:= 'string A';
> end;
>
> var
> RecPtr: PSomeRec;
> begin
> new(RecPtr);
> ChangeRec1(RecPtr);
> writeln(RecPtr^.a);
> dispose(RecPtr);
> readln;
> end.
Only the pointer itself is the parameter and read-only. Where the pointer
points to is irrelevant.
_______________________________________________
fpc-pascal maillist - [email protected]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal