Michael Van Canneyt het geskryf: > > You only need var/out when you want to change the instance pointer, i.e. > switch to another instance. And I count FreeAndNil() among this. (.Free > on the other hand is still possible, but not recommended). > > If you just want to set properties or call methods on an existing instance, > there is no need to use out or var.
Thank you Michael, I understand it much better now. Could you please add this information into the FPC Language Reference document? I re-read Chapter 11 in ref.pdf and there is no mention of what you said, and the documentation doesn't cover what happens if a Class is passed as a parameter. It only mentions simple types and arrays as parameters. Maybe adding a extra section in that chapter explaining when to use what? This brings me to another question. What is supposed to happen if you pass a Class instance as a const parameter? Does that even make sense? If not, why does the compiler allow that? Again, the documentation doesn't cover this scenario. Same question applies to passing a record structure. eg: ---------------------------- procedure ProcessPerson(const APerson: TPerson); begin ... // Am I allowed to change APerson.Name property? ... // Am I allowed to assign a new instance to APerson? end; ... lPerson := TPerson.Create; lPerson.Name := 'Graeme Geldenhuys'; ProcessPerson(lPerson); ---------------------------- * I see I can't assign a new instance to APerson - this makes sense. * I can assign new values to APerson.Name - am I supposed to be allowed to do that? Regards, - Graeme - -- fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal http://opensoft.homeip.net/fpgui/ _______________________________________________ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel