Request: (T) == T

Janice Caron caron800 at googlemail.com
Tue Dec 11 23:33:34 PST 2007


On Dec 12, 2007 4:45 AM, Walter Bright <newshound1 at digitalmars.com> wrote:
> Janice Caron wrote:
> > This would be useful for generic programming, mixin strings, etc.
>
> Please post an example where it would be useful.

This function expects constancy to be one of "const", "invariant" or "".

    string newType(string constancy, string oldType)
    {
        return constancy ~ "(" ~ oldType ~ ")";
    }

But I guess the real answer is aesthetics. We understand parentheses
to imply precedence, so naturally we expect the value expression (x)
to evaluate to x. It just seem intuitively write that the same should
be true of type expressions, that the type expression (T) should
evaluate to T.

This isn't a big deal. Say no if you like; I'm not going to argue
furiously for this one. It just seems aesthetically right.



More information about the Digitalmars-d mailing list