Mixin template evaluated to string can convert to string mixin expression implicitly
Timon Gehr
timon.gehr at gmx.ch
Fri Jun 24 08:31:18 PDT 2011
kenji hara wrote:
> Issue in bugzilla:
> http://d.puremagic.com/issues/show_bug.cgi?id=6207
> Test implementation:
> https://github.com/9rnsr/dmd/commit/52e4491cf6bf9ccf6dccc1fa60581fd6797d39b3
>
> String mixin feature in D is very useful, but its syntax is bit ugly.
> My proposal will make it more softly, and introduces more generative
> programming.
>
> Any thoughts?
>
> Kenji
String mixins themselves are 'a little bit ugly' (but unquestionably very useful).
I think the syntax should keep reflecting that.
Your proposal is a try to make up for Ds lack of macros. I'd prefer macros.
Also overloading the meaning of 'mixin template' seems to be questionable. As I
understand it, your proposal would make code like this valid?:
mixin template bar(bool b){
static if(b){
enum bar="foo(123);"
}else{
int foo(int x){
return 123+x;
}
}
}
int main(){
mixin bar!(0);
int x=bar!(1);
assert(x == 246);
}
This does not seem quite right to me.
Cheers,
-Timon
More information about the Digitalmars-d
mailing list