Thanks to all three of you for your responses--very helpful. As I think 
about it, it seems almost intuitive (after a couple days :-) that objects 
should be freed by the same class instance in which they were created, if 
possible. I appreciated your responses about passing parameters, too, and 
started experimenting a little, just to cement my understanding.

I created a class called TSample with a single procedure, test 
(sl:TStringList). It's got two lines: sl.Add('TSample'); and 
ShowMessage(sl.Text). I experimented with calling the procedure, passing the 
stringList in various ways. I understood, I'm happy to say ... except for 
this:

Form1's got this code:
sl:=TStringList.Create;
sl.Add('TForm1');
x:=TSample.Create;
x.test(sl);
sl.Add('TForm1 again');
ShowMessage(sl.Text);
sl.Free;

The last ShowMessage has all *three* lines ('TForm1','TSample', and 'TForm1 
again'). It seems to me that if it's a *copy* of sl that's passed to the 
called procedure, then that last ShowMessage should just have *two* lines 
('TForm1' and 'TForm1 again'). In other words, it seems like the procedure 
is acting the way I would now predict it would (and does) if I change the 
signature to TSample.test (var sl:TStringList).

What do you think?

Thanks, as always -- Al

p.s. I'll stop asking so many questions soon ... don't want to overstay my 
welcome :-)

_________________________________________________________________
Express yourself instantly with MSN Messenger! Download today - it's FREE! 
http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/

_______________________________________________
Delphi mailing list -> [email protected]
http://www.elists.org/mailman/listinfo/delphi

Reply via email to