question...

Bill Baxter dnewsgroup at billbaxter.com
Wed Jan 9 16:01:02 PST 2008


Aziz K. wrote:
> Marcin Kuszczak wrote:
>> Thanks but explanation. But I think that somethink is wrong here anyway.
>> Please see first example. 'A' is also not expression, but it compiles
>> properly. Maybe it would not be a big problem to extend typeof in such a
>> way that it can accept types also.
>>
> 
> This is the example:
> class A {}
> static assert(is( typeof(new A) == typeof(A)) ); // 1
> [...]
> You suggested to extend typeof to allow Types as well. I don't think 
> that's a good idea and I think it's not going to happen (ie. Walter 
> won't implement it.) The reason is that typeof has one perfect purpose, 
> that is to get the type of an expression. I don't see any sense in 
> passing a Type to typeof in order to get what you had in the beginning 
> anyway. Maybe there could be a legitimate use-case for this, but I'd 
> like to see convincing examples where this would be meaningful and useful.

Yes, if anything typeof(A) should logically be "Type".  I.e. the type of 
types. (which is what you get in Python and probably other languages 
with first-class types)

--bb



More information about the Digitalmars-d-learn mailing list