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

Derek Parnell derek at psych.ward
Tue Nov 3 13:27:56 PST 2009


On Mon, 02 Nov 2009 17:47:53 +0100, Don wrote:


> 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>).

Thank you Don for this "voice of reason". A specific keyword for the
concept of compile-time activity/functionality is totally justified.

"meta" is very suitable. Short and to the point.

"compiler" I could live with.

"traits" is unsuitable, as it is too limiting a concept.

"scope" is unsuitable, as it is already too highly overloaded with
semantics.

"static" is extremely unsuitable. This word should, at best, be only used
for things that do not change value or location during run-time.

... and slightly off topic ...
now if only we could get the 'bang' out of template instantiation syntax as
well. When I see the '!' in something like "Foo!(X)()", my mind first says
"we are about to negate something" and then has to switch tracks "oh no,
this actually means we are using a template this time". I'm *so* over the
amount of symbol and keyword overloading that goes on in D and C-like
languages. It's as if they were devised by academics during the days when
data transmission times were slow and only they looked at source code. 

-- 
Derek Parnell
Melbourne, Australia
skype: derek.j.parnell



More information about the Digitalmars-d mailing list