[Issue 6091] New: [d-p-l.org] Description for "Modifier casting" is misleading

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Jun 2 12:40:33 PDT 2011


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

           Summary: [d-p-l.org] Description for "Modifier casting" is
                    misleading
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: websites
        AssignedTo: nobody at puremagic.com
        ReportedBy: schveiguy at yahoo.com


--- Comment #0 from Steven Schveighoffer <schveiguy at yahoo.com> 2011-06-02 12:36:08 PDT ---
>From this page: http://d-programming-language.org/expression.html

------
Casting to a CastQual adds the qualifier to the type of the UnaryExpression.

Casting to the empty ( ) has the effect of removing any top level const or
immutable type modifiers from the type of the UnaryExpression.
------

When I read this, I interpret casting to a CastQual as only *adding* the given
modifiers, but it actually *replaces* the modifiers.

For example:

shared int x;
assert(is(typeof(cast(const)x) == const int));

Note, shared is *removed* from the modifiers.

For the second statement, casting with ( ) removes shared as well:

shared int x;
assert(is(typeof(cast()x) == int));

Finally, "Casting to the empty ( )" reads poorly.

I would say "Cast with no Type or CastQual inside the parentheses has the
effect of removing any top level const, immutable, or shared type modifiers
from the type of the UnaryExpression."

I also would like to see examples here, feel free to use my two above.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list