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

Leandro Lucarella llucax at gmail.com
Mon Nov 2 15:51:23 PST 2009


Don, el  2 de noviembre a las 20:19 me escribiste:
> >>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...
> >
> >And I'll be darned if "static" isn't the perfect fit :o).
> 
> I suggested 'scope', as well, if you need to minimize keywords.
> You can get rid of typeid, though, which is a real keyword, by
> moving it to the same namespace.

I think typeof can be moved there too, maybe pragma too (or completely
replace pragma with meta: meta.msg("hello"), meta.lib("mylib"),
meta.startaddress(foo)). There might be even more.

> >>This would give us:
> >>
> >>meta.compiles(XXX)
> >>meta.isArithmetic; // note, property syntax OK if no arguments
> >>meta.isArithmetic(int*);
> >
> >isArithmetic is library-implementable. How would the library
> >inject stuff in the meta namespace?
> 
> It could be done from inside traits.c in the compiler. If the
> function isn't on the list of instrinsics, it can be converted into
> a function call in the same name.
> 
> Also my alarm goes off when seeing
> >meta.isArithmetic(int*) instead of meta.isArithmetic!(int*), which
> >is what the unwashed masses would have to do if they wanted to
> >implement a similar facility. With time I've acquired a dim view
> >of certain stuff in the language benefiting of untouchable
> >advantages.
> 
> Agree, and that's what I see a severe problem with __traits --
> nothing in the language looks ANYTHING like it.

I don't know if you're talking about the __ or the syntax, but pragma
follows the same syntax pattern, and do compile-time stuff, so I guess
it's a good candidate for meta too.


-- 
Leandro Lucarella (AKA luca)                     http://llucax.com.ar/
----------------------------------------------------------------------
GPG Key: 5F5A8D05 (F8CD F9A7 BF00 5431 4145  104C 949E BFB6 5F5A 8D05)
----------------------------------------------------------------------
Un paracaidista, que no deja de caer.
Lo que me lleva hacia arriba, es lo que me tira hacia abajo.



More information about the Digitalmars-d mailing list