CVS difference for ais/ai-00251.txt

Differences between 1.32 and version 1.33
Log of other versions for file ais/ai-00251.txt

--- ais/ai-00251.txt	2005/06/16 23:47:15	1.32
+++ ais/ai-00251.txt	2005/07/28 02:30:07	1.33
@@ -5423,6 +5423,117 @@
 
 ****************************************************************
 
+From: Adam Beneschan
+Sent: Thursday, April 21, 2005  7:47 PM
+
+!topic Can interface types have discriminants?
+!reference RM2006 3.9.4, 3.2, 3.7, AI-251
+!from Adam Beneschan 05-04-21
+!discussion
+
+
+There seems to be a small hole that could lead to confusion.
+
+The chart in 3.2(12) implies that interface types are composite types.
+Yes, I realize that this isn't really a language rule since it's in a
+Note.  3.2(3-4) lists which types are elementary types and which types
+are composite types.  Interface types aren't listed in either one;
+3.2(4) says "The composite types are the record types, record
+extensions, array types, task types, and protected types", and I don't
+see anything that says that an interface type is a record type.
+(3.9.4 says an interface type is a tagged type, but nothing in 3.9
+says that all tagged types are record types.)
+
+3.7(1) says, "A composite type (other than an array type) can have
+discriminants".  Since 3.2(12) seems to imply that an interface type
+can be a composite type, 3.7(1) would seem to allow interface types to
+have discriminants.
+
+3.9.4(6) says, "An interface type has no components".  In the AARM,
+this sentence is in square brackets, and there's a note that says
+"This follows from the syntax".  But it doesn't, because "the syntax"
+of 3.2.1(3) allows type declarations to have known discriminant parts,
+and if we assume an interface type is a composite type, 3.7(1) also
+allows interface types to have discriminants.  A discriminant is a
+component.  (3.8(9) is explicit in saying that the discriminants of a
+record type are components of the record; but for non-record and
+non-array types, the only place that seems to say that a discriminant
+is a component is 3.2(5).)  So without 3.9.4(6), it appears that it
+would be legal for an interface type to have a discriminant, but
+3.9.4(6) makes this illegal, meaning it shouldn't be in square
+brackets in the AARM.
+
+AI-251 (including the appendix) makes no mention of the issue of
+whether interface types can have discriminants---nobody seems to have
+thought about this possibility, even to point out that it should be
+illegal.  I don't see any reason for interface types to have
+discriminants, and I think they would cause a headache, so I'm
+assuming they're disallowed.  But trying to find the answer to the
+question "Can interface types have discriminants?" in RM2006 led me
+down what seems to be a tortuous path.
+
+My suggestions, to clear up any possible confusion: (1) Fix 3.2(4) to
+include "interface type" in the list of composite types; (2) fix
+3.7(1) to say "A composite type (other than an array type or an
+interface type) can have discriminants."
+
+****************************************************************
+
+From: Tucker Taft
+Sent: Thursday, April 21, 2005  8:18 PM
+
+> AI-251 (including the appendix) makes no mention of the issue of
+> whether interface types can have discriminants---nobody seems to have
+> thought about this possibility, even to point out that it should be
+> illegal...
+
+Discriminants were discussed and it was clear
+they were inappropriate, as they create all the
+same headaches as multiple inheritance of components,
+as well as several other headaches unique to discriminants.
+As you suggest, this analysis should have been captured
+in AI-251.
+
+> ...
+> My suggestions, to clear up any possible confusion: (1) Fix 3.2(4) to
+> include "interface type" in the list of composite types; (2) fix
+> 3.7(1) to say "A composite type (other than an array type or an
+> interface type) can have discriminants."
+
+Sounds like a reasonable suggestion...
+And thanks for the thoughtful analysis.
+
+****************************************************************
+
+From: Bob Duff
+Sent: Friday, April 22, 2005  7:16 AM
+
+Adam Beneschan wrote:
+
+> AI-251 (including the appendix) makes no mention of the issue of
+> whether interface types can have discriminants---nobody seems to have
+> thought about this possibility, even to point out that it should be
+> illegal.
+
+Well, a couple of months ago, I thought about the possibility,
+and I asked Tucker, "Can interfaces have discriminants?".  ;-)
+He said no.  That makes sense; allowing them would cause
+implementation headaches similar to normal components.
+One could no longer assume that record layout is the same
+for all types in a class.
+
+I'm not sure if there are any semantic problems as well.
+Since discriminants are constant, the classic "diamond pattern"
+of multiple inheritance doesn't cause as much trouble,
+because it doesn't really matter whether constants are
+duplicated.
+
+Anyway, the intent was definitely to disallow discrims.
+
+Nice exegesis by the way.  ;-)
+
+****************************************************************
+
 From: Bob Duff
 Sent: Monday, June  6, 2005  12:36 PM
 

Questions? Ask the ACAA Technical Agent