Robert Meek wrote: > What I'm glad I finally did get out of my questioning was Rob's > information on how use within an array inhibits the normal reference > counting Delphi uses
You misinterpreted my article. It's _not_ the array that circumvents reference counting. It's the use of Move to quickly shift everything around in the array. I think the article is pretty clear about that. I was about to provide an example here to demonstrate how to modify a dynamic array without using Move, Initialize, and Finalize, to show that it's perfectly safe, but what I came up with turned out to be exactly what I gave in listing 1. As I look at the article now, I see that I really should re-organize it; I shouldn't mention Move so early, lest it appear that it's the preferred technique. > as I never would have considered that and would have > ended up with some pretty nasty memory leaks that would be difficult to > account for! <g> And not just memory leaks. Access violations or invalid-pointer operations, too. > I personally consider this difficulty a very un-natural > condition that should have been accounted for properly by the compiler. It was. But Move circumvents any type-checking the compiler could do. As type-safe as Delphi is, and untyped var and const parameters are one glaring hole in it, as the names would imply. > Looking into this mystery I learned things about the way Delphi manages > strings and other reference counted objects that I didn't know about. There > are probably many very good reasons for why they did these things as they > did, but just from my shortsighted view of it all I think I would have > handled these things a little closer to the bone...meaning that I would have > made the allocation and freeing of memory needed for their dynamic sizing a > part of the objects themselves. They're not objects. And the allocation is handled as part of the language itself. You can't get any closer to the bone than that when you're designing a programming language. > I've never been comfortable with the > concept of an object's use affecting its natural behaviour. I don't think I know what that means. -- Rob _______________________________________________ Delphi mailing list -> [email protected] http://www.elists.org/mailman/listinfo/delphi

