On Friday 17 October 2014 19:26:56 Mathias Hasselmann wrote: > > Shoot the developer who abused the API. > > > > If the function accepts enum values 1 and 2 and you pass a 3, you deserve > > the undefined behaviour. > > > > That is the same as passing a bool that doesn't contain exactly values 0 > > or 1 or passing an uninitialised pointer. > > > > We have to handle all regular conditions. We don't have to guard against > > stupidity. > > I don't think this example has to do with stupidity. To me this just > seems like a minimal example of typical integration problems that happen > in real world. Far fetching I'd talk about distributed services, reading > files written by a different program version, and such. Also Qt already > deals with such issues where it is obvious: > > const char * QVariant::typeToName(int typeId) [static] > Converts the int representation of the storage type, typeId, to its > string representation.
That's not a good example. My point is that an API that is documented to have only values 1 and 2 should not have to handle value 3. That is not the case of dealing with metatypes. That's why in most cases we actually use ints, as shown above, than the enums from QVariant and QMetaType. If you abuse an API, you deserve crashes. I will not support changes to Qt that try to deal with stupidities. -- Thiago Macieira - thiago.macieira (AT) intel.com Software Architect - Intel Open Source Technology Center _______________________________________________ Development mailing list [email protected] http://lists.qt-project.org/mailman/listinfo/development
