----- Original Message -----
> From: Sönke Ludwig <[email protected]>
>
> Artificial example (I have a different use case, but the pronciple is
> similar):
> 
> interface ILinkedListItem {
>   LinkedListItem next();
>   void next(LinkedListItem v);
> }
> 
> LinkedList objectStore;
> 
> class C : protected ILinkedListItem {
>   this()
>   {
>     objectStore.add(this);
>   }
> 
>   protected LinkedListItem next() {...}
>   protected void next(LinkedListItem v) {...}
> }
> 
> So the intent is that you don't have access to these methods from the
> outside, but that C can still implement the interface to pass it only to
> certain receivers (the objectStore list in this case).

1. using a template for a container like linked list is preferred to using 
interfaces.
2. you can achieve something similar using inner classes or class literals:

class C
{
   private class LLItem : ILinkedListItem{
      LinkedListItem next() {...}
      void next(LinkedListItem v) {...}
   }

   this()
   {
       objectStore.add(new LLItem);
   }
}

-Steve

_______________________________________________
dmd-beta mailing list
[email protected]
http://lists.puremagic.com/mailman/listinfo/dmd-beta

Reply via email to