Francoise Martinolle wrote: > Can you use logical equality and inequality for class handles which are > not of the same class hierarchy or which are > in the same class hierarchy but different derived classes? [...] > My opinion is that only class handles of the same class data type can be > compared. Since "==" is a handle comparison, the least restrictive approach would be to just allow any comparison. The LRM doesn't define rules for this; I prefer minimal restrictions here. > Depending on what we decide here, has an impact on the conditional > operator. Today the LRM section 8.18 > requires that the datatype of the true and false arms be equivalent. The > LRM defines that 2 class datatypes > are equivalent if they match, so this seems to imply that you have to > have the same > class datatype. so the following ex is illegal: > > b1 = (cond ? b :c); // Note that either assigment of b or c to b1 are > legal (not the case if I had c1 = (cond? b:c); > > but you can write: > b1 = (cond ? b : b1); > > Can you write > b1 = (cond ? b : null) ; since null does not have a datatype? My view of the conditional operator for classes is that they should allow anything on either branch that is assignment compatible with the target. > What happen in the above case if the condition is X? How do we compare > each field of b and null? They probably do not compare equal so > the assigned value to b1 should be null. I don't think that property comparison is correct for classes. If the *handles* are not the same, you get null, otherwise you get the handle. This makes things reasonable when combined with the "assignment compatible" view of the conditional operator for classes. This is not what the LRM currently says, but I think it is likely what people expect and what makes the most sense for classes. Gord -- -------------------------------------------------------------------- Gordon Vreugdenhil 503-685-0808 Model Technology (Mentor Graphics) gordonv@model.comReceived on Fri Sep 15 08:18:37 2006
This archive was generated by hypermail 2.1.8 : Fri Sep 15 2006 - 08:18:46 PDT