[Issue 632] New: Typedef promotions spec ambiguous - ultimate base type or lowest common denominator?

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat Dec 2 18:42:39 PST 2006


http://d.puremagic.com/issues/show_bug.cgi?id=632

           Summary: Typedef promotions spec ambiguous - ultimate base type
                    or lowest common denominator?
           Product: D
           Version: 0.175
          Platform: All
               URL: http://www.digitalmars.com/d/type.html
        OS/Version: All
            Status: NEW
          Keywords: spec
          Severity: normal
          Priority: P2
         Component: www.digitalmars.com
        AssignedTo: bugzilla at digitalmars.com
        ReportedBy: smjg at iname.com
OtherBugsDependingO 511
             nThis:


"# If one operand is a typedef and the other is the base type of that typedef,
the result is the base type.
# If the two operands are different typedefs but of the same base type, then
the result is that base type."

By "base type", does it mean the built-in type from which the typedef is
ultimately derived, or the most-derived type that is a common base to both (the
lowest common denominator)?  In particular, it's tempting to think that, given

    typedef int qwert;
    typedef qwert yuiop;
    typedef qwert asdfg;

that the "base type" in question is qwert, which is the immediate parent type
of yuiop and adsfg, and hence that an expression involving any two of these
typedefs will promote to qwert.  This is similar to the common use of "base
class" in OOP lingo.

The better way, IMO, is to define such promotions to be to the lowest common
denominator type.  Consequently, any typedef (other than one of a type that's
always subject to integer promotions, but that's another matter) would be
closed under arithmetic operations.  I imagine that implementing this principle
in the compiler wouldn't be difficult.

Please see
http://www.digitalmars.com/pnews/read.php?server=news.digitalmars.com&group=digitalmars.D&artnum=44821
for further commentary.

But whichever method is chosen, the spec needs to be made clearer.


-- 




More information about the Digitalmars-d-bugs mailing list