Request: (T) == T

Walter Bright newshound1 at digitalmars.com
Wed Dec 12 00:46:30 PST 2007


Janice Caron wrote:
> 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 ~ ")";
>     }

	return constancy.length ? constancy ~ "(" ~ oldType ~ ")" : 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.

I don't know any language that does this, or where the lack of it was 
even noticed.


> 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.

There are so many things that need to be done, I can't see this as being 
needed.



More information about the Digitalmars-d mailing list