karl@haddock.ISC.COM (Karl Heuer) (07/20/87)
In article <732@jenny.cl.cam.ac.uk> am@cl.cam.ac.uk (Alan Mycroft) writes: >The problem is that C does not include all the operations one would expect on >union types... In C we could say > union intorptr { int a; char *b;}; > extern f(union intorptr); > g() { f((union intorptr)3);} NOT IN ANSI. I can't find any mention of this in the Rationale document, but I presume the reason X3J11 didn't add this (assuming they thought of it) is the usual Lack of Prior Art. The way to get this into the *next* standard is to convince vendors to add it as an extension. Now, let's examine this idea. I like the semantics, but the syntax isn't all-powerful. What if you want to initialize a member of a non-rvalue type, such as "char" or "short"? Does it only work if there is no "int" member for it to conflict with? Given a union of { long; char[4] }, can you initialize the array member? How? These questions need to be addressed, and it would be inappropriate for X3J11 to do so. Karl W. Z. Heuer (ima!haddock!karl or karl@haddock.isc.com), The Walking Lint