On Apr 11, 2007, at 7:11 AM, Daniel Stenning wrote: > It is good to have this new feature, but since Parent-Child > relationships > are found all over the place ( at least in my code they are ) and the > scenarios presented seem to me anything but "rare" - am I alone in > thinking > that the way this feature was implemented is a "fudge" ? : > > > a) because it loses the typing information - it is generic for all > objects. > This adds to tedium as one has to apply lots of casting. > > b) the amount of coding involved to create and deal with this object. > > A much better solution would have been to use "Weak" instead of Dim in > source code, and for properties to have a checkbox named "weak", > making all > the mechanics of handling weak references internal. Current > references I > would bet are some form of hidden C++ "smart-pointer" object, and > so should > weak references be. > > I think that to leave WeakRef as a class, partly to prevent people > from > wrongly using this feature everywhere, is misplaced. By all means > present > warnings during syntax check ( turn-offable in preferences ) to > warn where > they are used, but for a professional tool, I think it is bad > form to make > a language feature unnecessarily hard and tedious to use, simply to > prevent > beginners from over-using this feature.
I believe that given the compiler's current architecture, or possibly just the time to implement it, it was impractical to implement typed weak references. In time, I believe the compiler may acquire type variables or templates or some such, which would allow for all kinds of things that take types as a parameter (eg Dictionary of String => Object), at which time I imagine that typed weak references will also appear. Note that you could create a subclass of WeakRef, that always returns the type you need, so you can almost implement typed weak references now. In a similar fashion, you can implement a Dictionary subclass that always fetches Foo objects from a String key. I am very happy to have weak references in any form. Regards, Guyren G Howe Relevant Logic LLC guyren-at-relevantlogic.com ~ http://relevantlogic.com REALbasic, PHP, Ruby/Rails, Python programming PostgreSQL, MySQL database design and consulting Technical writing and training _______________________________________________ Unsubscribe or switch delivery mode: <http://www.realsoftware.com/support/listmanager/> Search the archives: <http://support.realsoftware.com/listarchives/lists.html>
