[fpc-pascal] const parameter writeable
mueller_michael at nikocity.de
Tue May 2 08:00:51 CEST 2006
On Mon, May 01, 2006 at 12:07:55PM -0600, L505 <fpc505 at z505.com> wrote:
> > > Only the pointer itself is the parameter and read-only. Where the pointer
> > > points to is irrelevant.
> I remember this from using classes where you can still access the class properties -
> should have thought about that before posing the question :).
> > But in this case I'm wondering why you want to give a pointer instead
> > of the real type?
> did you mean this ? :
> procedure ChangeRec1(const Rec: TSomeRec);
> Rec.a:= 'string A';
> Because I can't pass a PSomeRec to that function, only a TSomeRec
Where is the problem? If you allocated the memory by new() as in your
example you could call
and the compile (hopefully) uses the pointer.
But in this case you will get an compiler error because you can't
change a constant value.
It seemed that I didn't get the point from your original mail:
Name the procedure CHANGERec1 and change a value but declare the
parameter as constant.
> Otherwise, I don't know what you mean..
Now _I_'m a little bit confused.
More information about the fpc-pascal