www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - Using disambiguated ctors/dtors from mixins.

Hi,

Maybe this is more a limitation or inconsistency than a bug, but anyway.

In a class, I can use a mixed in constructor.
When multiple mixins define a function with the same name, they can be 
disambiguated with a mixin identifier.
A mixed in constructor can be overridden.

But: when multiple mixins define a constructor, there is no way to use 
them. The code below gives

override.d(17): identifier expected following '.', not 'this'
override.d(17): identifier expected following '.', not 'this'

Commented out is a working constructor that uses mixed in functions, the 
same way as I want to use mixed in constructors.


#template Foo()





#template Bar()





#class FooBar















#void main()




It has its application in achieving multiple inheritance (derive from 
multiple interfaces and mix in multiple implementations, then override 
conflicting functions and merge their functionality). The limitation can 
be worked around by taking the contents of constructors out in, say 
func(), and use the part that is commented out above in stead.

Bastiaan.
Sep 22 2004