dmd 1.057 and 2.041 release

Adam Ruppe destructionator at gmail.com
Mon Mar 8 07:36:17 PST 2010


> __traits allMembers and and derivedMembers now return a tuple of strings rather
> than an array of strings. Enclose __traits in [ ] to make array literal. This makes it
> possible for foreach statements to iterate at compile time over it.

How exciting!

On 3/8/10, Trass3r <un at known.com> wrote:
> Is there a better way to use the new operator overloading than string
> mixins?
>
> Also the following code strangely yields:
> dsfml\system\vector2.d(47): Error: variable
> dsfml.system.vector2.Vector2!(float).Vector2.op only parameters or foreach
> declarations can be ref
>
> /// element-wise operations, +, -,
> ref Vector2 opBinary(string op)(ref Vector2 v)
> {
> 	mixin("return Vector2!(T)( cast(T)(x " ~ op ~ " v.x), cast(T)(y " ~ op ~ "
> v.y) );");
> }
>
> Removing ref from the return type makes it compile.
>
>
> Furthermore the assignment operator seems to be rewritten as opBinary
> instead of opAssign as the docs state:
>
> Vector2f	_pos = Vector2f(0.f, 0.f);
> yields:
> Error: template instance opBinary!("=") matches more than one template
> declaration
>
>
> This also shows another problem. It can't distinguish between these two:
> Vector2 opBinary(string op)(ref Vector2 v)
> if (op != "*")
> {
> 	mixin("return Vector2!(T)( cast(T)(x " ~ op ~ " v.x), cast(T)(y " ~ op ~ "
> v.y) );");
> }
>
> Vector2 opBinary(string op)(int i)
> {
> 	mixin("return Vector2!(T) ( cast(T)(x " ~ op ~ " i), cast(T)(y " ~ op ~ "
> i) );");
> }
>
> even though vec1 + vec2 resp. vec + 5 is unambiguous.
>


More information about the Digitalmars-d-announce mailing list