On Tuesday, 26 November 2013 at 06:40:24 UTC, Ali Çehreli wrote:
On 11/25/2013 09:11 PM, Frustrated wrote:
> On Tuesday, 26 November 2013 at 05:03:45 UTC, Ali Çehreli
wrote:
>> On 11/25/2013 04:27 PM, Frustrated wrote:
>>> I have some type of automatically generated interface using
a mixin an
>>> would like to extend them after they are generated:
>>>
>>> mixin(GenerateMyInterface!(...));
>>>
>>> ... <Here I would like to add some members/methods to
MyInterface
>>> which was generated above> ...
>>>
>>> Is this at all possible?
>>>
>>>
>>
>> Just inherit from it:
>>
>> interface MyInterface
>> {
>> void foo();
>> }
>>
>> interface EvenMoreMyInterface : MyInterface
>> {
>> void bar();
>> }
>>
>> Ali
>
> No, this is not the way. I am creating the interface and need
to add to
> it only because it is generated.
I can be very thick sometimes. :) How about changing the names
of the interfaces:
interface LessMyInterface
{
// ...
}
interface MyInterface : LessMyInterface
{
// ...
}
> If I inherit from it then I would have to update all
references that use the
> interface to use the new one.
No code needs to be changed. Everybody keeps using MyInterface.
Ali
This may work, even though it pollutes the namespace. Probably
not a big deal though, better than having to completely generate
the interface as a string(which offers very little compilation
support(syntax errors, etc). It would be nice to have partial
classes similar to C# even if they have to be in the same module
which may seem pointless but with mixins it would definitely
solve my problem.