http://d.puremagic.com/issues/show_bug.cgi?id=3702
Nick Treleaven <[email protected]> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |[email protected] --- Comment #4 from Nick Treleaven <[email protected]> 2013-07-16 07:29:48 PDT --- (In reply to comment #0) > 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. ... > meta.compiles(XXX) > meta.isArithmetic; // note, property syntax OK if no arguments > meta.isArithmetic(int*); I support this, but I think using template instantiation syntax might be even better, to help avoid brackets for simple cases: meta.isArithmetic!int meta.isArithmetic!(i, i+1) meta.isArithmetic // could be OK, otherwise append !() meta.parent!T meta.typeid!x For simple code snippets, brackets as proposed don't seem too bad. But we know how much nesting often happens in complex code, and eliminating brackets in a complex expression is a clear win for readability. __traits(compiles, ...) must be the most commonly used trait, and I think it's very often used with nullary delegate literals. So I also propose this special case: meta.compiles!{...} Here, the () brackets after '!' are not required because the braces are enough. compare with: meta.compiles({...}) __traits(compiles, {...}) is(typeof({...})) It would be really nice to have 'meta' as a keyword, it could also be used for manifest constants, instead of enum: meta five = 5; But people may already be using the identifier 'meta', e.g. in a module name, xtd.meta. Perhaps we should make meta a 'soft' reserved word. I.e. it is allowed as an identifier, but the compiler prints a message 'Note: meta may become a reserved word in later versions'. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
