Proposal: Replace __traits and is(typeof(XXX)) with a 'magic namespace'.

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Mon Nov 2 10:40:22 PST 2009


Steven Schveighoffer wrote:
> On Mon, 02 Nov 2009 13:17:18 -0500, Andrei Alexandrescu 
> <SeeWebsiteForEmail at erdani.org> wrote:
> 
>> Don wrote:
>>> [I'm moving this from deep inside a TDPL thread, since I think it's 
>>> important]
>>>  is(typeof(XXX)) is infamously ugly and unintuitive
>>> __traits(compiles, XXX) is more comprehensible, but just as ugly.
>>>  They are giving metaprogramming in D a bad name. I think we need to 
>>> get rid of both of them.
>>>  A very easy way of doing this is to replace them with a 'magic 
>>> namespace' -- so that they _look_ as though they're functions in a 
>>> normal module.
>>> Names which have been suggested include 'meta', 'traits', 'scope', 
>>> 'compiler'. Personally I think 'meta' is the nicest (and I suggested 
>>> two of the others <g>).
>>
>> Another keyword, sigh...
> 
> Wouldn't meta *replace* a keyword?  i.e. no more __traits.
> 
> Maybe I misunderstand the proposal, but that's what I thought.
> 
> -Steve

It would, but all symbols starting with __ are already reserved.

Andrei



More information about the Digitalmars-d mailing list