On 03/20/2012 11:25 AM, Mantis wrote:
Hello,

since people discussed a lot about user-defined attributes recently,
I've been thinking about a way to implement it with a string mixins. The
problem with them is their syntax - it's far from what we want to use in
everyday job. I understand, they should be easily distinguished at use
site, but perhaps this may be accomplished in other ways as well. My
idea is to translate this kind of statements:

# identifier statement

into this:

mixin( identifier( q{ statement } ) );

No no no no, oh the humanity no!

String mixins should be a method of LAST resort. Please don't add sugar to make them look nicer. If anything add vinegar and make them look as ugly as they really are.


where an identifier is a, possibly templated, function that accepts one
string argument and returns a string. Here are some possible use cases:

#serialize int a; // marked to be serializable
#serialize!not int b; // -.- non-serializable

#readonly float c; // generate trivial private setter and public getter

#handles!Events.Foo void handler(); // event handler

#attribute!"Foo" void foo(); // function with additional compile-time info

Most of these examples require some D parser, but, since it is planned
to add parser-generation into Phobos, this shouldn't be a problem.
What do you think, does it have some value for the language, and, if
yes, is it possible to implement?

Reply via email to