I know Chuck noticed in my code postings that I annotate all my collections and enumerations with a generic label. For example:

        NSArray /*[String]*/ string_array = new NSArray ();
        Enumeration /*[String]*/ e = string_array.objectEnumerator ();

but this is just dumb documentation and now Java 1.5 has generics for real (and they seem to have done a good job with type conformance rules and constrained genericity (wonder where they got that from, although they have had enough languages do generics before, even C++ with its awful templates). Real generics get rid of all those horrible type casts and better still any runtime ClassCastExceptions (making runtime code more efficient too).

Is there any indication that WO will adopt genericity in the near future. I have looked at making subclasses of NSArray and NSMutableArray (XNSArray <T> and XNSMutableArray <T> respectively), but you can't assign an XNSMutableArray to XNSArray, since XNSMutableArray <T> is not a subclass of XNSArray <T>.

So you are really stuck with adding the generic parameter to the original classes, NSArray <T> and NSMutableArray <T>, and this change does not break any existing code which uses them unparameterized (I think, I have not read it all yet).

EO- and WODisplayGroup would also be good to have a generic parameter so you could have

        EODisplayGroup <My_entity> dg;
My_entity m = dg.selectedObject (); // No cast or possibility of run-time ClassCastException.

        for (My_entity me: dg.selectedObjects ()) {
                ... do something to me
        }

Any rumblings that genericity might happen soon?

Ian

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      ([email protected])
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to