> > >
> > > 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
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
>
> > 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.
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
> > 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
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
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
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
>
> 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
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
10 matches
Mail list logo