Re: [fpc-pascal] const parameter writeable

2006-05-02 Thread L505
> > > > > > 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); > >begin > > Rec.a:= 'string A'; > >end; > > Yes. Well, this is a Precord. That doesn't wor

Re: [fpc-pascal] const parameter writeable

2006-05-01 Thread Michael Müller
On Mon, May 01, 2006 at 12:07:55PM -0600, L505 <[EMAIL PROTECTED]> 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 thou

Re: [fpc-pascal] const parameter writeable

2006-05-01 Thread L505
> > > did you mean this ? : > > > >procedure ChangeRec1(const Rec: TSomeRec); > >begin > > Rec.a:= 'string A'; > >end; > > > > Because I can't pass a PSomeRec to that function, only a TSomeRec > > Then pass a PSomeRec^ to it if you don't intend to change the pointer > anyway.

Re: [fpc-pascal] const parameter writeable

2006-05-01 Thread Jonas Maebe
On 01 May 2006, at 20:07, L505 wrote: did you mean this ? : procedure ChangeRec1(const Rec: TSomeRec); begin Rec.a:= 'string A'; end; Because I can't pass a PSomeRec to that function, only a TSomeRec Then pass a PSomeRec^ to it if you don't intend to change the pointer anywa

Re: [fpc-pascal] const parameter writeable

2006-05-01 Thread L505
> > 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 yo

Re: [fpc-pascal] const parameter writeable

2006-05-01 Thread Jonas Maebe
On 01 May 2006, at 08:11, Michael Müller wrote: - 'const': gives pointer, content read-only The compiler can handle const parameters in any way it wants, and it may even differ among different cpu's and calling conventions. Sometimes they are passed by value, sometimes by reference. It

Re: [fpc-pascal] const parameter writeable

2006-04-30 Thread list
Michael says: > - 'const': gives pointer, content read-only In practice the compiler may[1] check for access to the value at compile time and just give you a pointer to the real thing (since it knows you won't change it). With a non-specified parameter it has to make a copy and pass that, which sl

Re: [fpc-pascal] const parameter writeable

2006-04-30 Thread Michael Müller
On Sat, Apr 29, 2006 at 11:20:04PM +0200, Peter Vreman <[EMAIL PROTECTED]> wrote: > > > > 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

Re: [fpc-pascal] const parameter writeable

2006-04-29 Thread Peter Vreman
> > 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(c

[fpc-pascal] const parameter writeable

2006-04-29 Thread L505
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); begi