Stewart, James wrote: > What do you all consider the best way to pass components (TDataSet, > TTabControl, etc) as parameters to a function or procedure call? > > VAR, CONST, or by Value? Which would give better execution speed or > memory managent? Is one way of passing the parameters better than > another?
I pass by value or const, depending on whether the object's properties are intended to be modifiable. Note that it technically makes no difference at all -- the properties are modifiable either way. My choice is purely for documentation. Do not pass by var or out unless you intend assign a new value to the parameter itself. That is, you will have a line like this: Parameter := NewValue; This does not count: Parameter.Field := NewValue; Neither does this: Parameter.Free; Neither of the latter cases involve changing the value stored in Parameter, so it does not need to be passed by reference. In fact, passing by reference severely limits what you can pass to the function: http://www.cs.wisc.edu/~rkennedy/var-identical -- Rob _______________________________________________ Delphi mailing list -> [email protected] http://lists.elists.org/cgi-bin/mailman/listinfo/delphi

