Patrick,
Objects are always passed by reference - because in Delphi, objects only
exists as references. Passing them by var will cause a reference to an
object reference to be passed. This is only useful if you want to return
object references in the procedure (which if that is the case, it is better
to use out instead of var). You don't need to pass by var even if you want
to call methods or modify fields / properties in the object.
Regards,
Dennis.
> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On
> Behalf Of Patrick Dunford
> Sent: Wednesday, 8 December 1999 12:59
> To: Multiple recipients of list delphi
> Subject: [DUG]: Passing objects as procedure parameters
>
>
> When you pass an object as a procedure parameter and you
> don't need to pass
> back any changes to the calling function, do you need the
> 'var' in front of
> the instance name in the procedure declaration?
>
> I routinely write procedures that receive tables and other
> instances that I
> want the changes passed back into the calling code (i.e.
> passed by reference
> rather than value). But since having a problem in Delphi 2 passing a
> TStringList as a value parameter into a procedure I have
> always routinely
> written 'var' to make the compiler pass the instance as a
> reference even
> though it isn't necessary to pass it back to the caller.
>
> That doesn't seem to apply in Delphi 3 as instances pass as
> value parameters
> fine (the compiler presumably still passes a reference rather than the
> object itself, though)
>
>
> --------------------------------------------------------------
> -------------
> New Zealand Delphi Users group - Delphi List -
> [EMAIL PROTECTED]
> Website: http://www.delphi.org.nz
>
---------------------------------------------------------------------------
New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
Website: http://www.delphi.org.nz