Why do template mixins have their own scope?

Timon Gehr timon.gehr at gmx.ch
Sun Jul 17 00:37:18 PDT 2011


Trass3r wrote:
> I know but what is so bad about issuing an error message and you rename
> one of the two.
> As I said it doesn't work out as soon as functions are involved.

First of all, you would break some existing code for no benefit, including code
that mixes in two templates with clashing members.

Furthermore, it would be more difficult to implement, because templates already
come with their own scope.

Mixin templates are there to allow mixing in declarations without coping with the
problems of string mixins. An own scope is pretty much required for that.

Therefore, I think mixin templates having their own scope is sensible.

The bug fix is to just search for constructors in mixin scopes too.

Cheers,
-Timon


More information about the Digitalmars-d mailing list