Alternative typeof syntax

Nick Sabalausky a at a.a
Mon May 17 16:18:54 PDT 2010

"bearophile" <bearophileHUGS at> wrote in message 
news:hss6b6$aep$1 at
> What do you think about the the syntax  x.typeof  instead of  typeof(x)  ?
> There are situations where you will need to parenthesize anyway, for 
> example:
> import std.stdio;
> void main() {
>    int x = 1;
>    float y = 1.5;
>    writeln(typeid(typeof(x + y)));
> }
> You have to write:
> (x + y).typeof
> But in many situations you don't need the ().
> And it gets more similar/uniform to the x.sizeof syntax too (that is 
> sizeof(x) in C).


Anything that reduces parenthesis-hell without inviting ambiguities in 
either the compiler or the "human-eye parser" is good by me :)

Besides, I love member access syntax in general. In addition to (safely) 
reducing parenthesis, it also sidesteps the oddity that nested function 
calls are written/read *backwards* from the order of execution (ie, 
"A(B(C()))" means "call C, then B, then A"). I've even been toying with the 
idea of a language design that places primary emphasis on member-call syntax 
and consistent left-to-right ordering.

More information about the Digitalmars-d mailing list