x.sizeof vs typeid(x)

Walter Bright newshound1 at digitalmars.com
Wed Feb 6 23:27:08 PST 2008


Robert Fraser wrote:
> Walter Bright wrote:
>> Sergey Gromov wrote:
>>> I wonder why .sizeof is implemented as a property while typeof() and
>>> typeid() are functions.  I can see no reasons for such inconsistency.
>>> It's not that obvious for typeof() because it yields a type instead
>>> of a value, but even then, why not ?
>>
>> Because expression.identifier always yields an expression, whereas 
>> typeof() always yields a type. It makes parsing easier and more 
>> consistent.
> 
> typeid yeilds an expression...

The subject says typeid, the post says typeof !

typeid(type) looks for a type between the parentheses, and a type has a 
different grammar than an expression.



More information about the Digitalmars-d mailing list