I was just reading MattWar's web log (The Wayward Weblog) about Generics in C#3.0. The article mentions that furure generics might be also tied to XML Types.I am not too sure I understand the concept. Well not at least the way it was described. To Quote:
The log goes futher, it describes how they are conceptually linked together. However, from what I have read, it is only the fact that a generic and an XML enclosure is syntatically similar by the use of angled brackets.Currently as I understand it generics, allow the use of parameterised specialisation of a class without having to re-write the class to handle different types of objects. For instance a list collection can be "bound" to an int, long, Cars, EarMuffs etc, and the type checking of the compiler will ensure that all uses are syntacitcally and sematically correct.The example of an XML Generics is Foo<int x ="..."/>, unfortuatly I don't really understand what is happenging there.
"On the surface, the two might seem to have nothing to do with each other, but if you dig deeper you soon realize that the two are fundamentally linked, the two concepts not separate but actually compliments of oneanother."
- Is the Foo parametised to an integer with a default value of "x";
- Is it a "Foo" element just simply with an attribute on;
- Is the "Foo" element constrained futher by the attributes on the XML element (see below);
- Is it that the Foo element is converted to a class and then parameterised with member variables, which are really XML attributes.
I just simply don't understand the point of XML Generics (using the blogs example). Why not generate your class from an XSD and paramaterise the type to the XSD'ed class.
Will future XML Generics be tied to a schema, so that parameters can be constrained via certain values (which I can see the point of, Foo<int type="xsd:positiveInteger" restriction="minValue"/> which would might constrain the Foo object to types on integers with a minValue) .I am really looking forward to futher information on this. Because I am sure it is correct that it is a shift and a major question to re-work my current understanding.
About Me: Paul Kinlan
I lead the Chrome Developer Relations team at Google.
We want people to have the best experience possible on the web without having to install a native app or produce content in a walled garden.
Our team tries to make it easier for developers to build on the web by supporting every Chrome release, creating great content to support developers on web.dev, contributing to MDN, helping to improve browser compatibility, and some of the best developer tools like Lighthouse, Workbox, Squoosh to name just a few.