Once Again, Feature Request: Nested classes in separate scope

David Wilson dw at botanicus.net
Tue Nov 6 04:18:17 PST 2007


On 11/6/07, downs <default_357-line at yahoo.de> wrote:
>
> That becomes a problem when you'd like to support many different types
> of windows and, well, don't want them _all in one file_.
>
> > Is the problem that you need to allow users to derive custom window
> > types from Window?
>
> Well, that too :p
>
> > I'm not sure if it's possible to derive from an
> > inner class or what the syntax would be if it was...

At present this throws the error:
    a.d(11): class a.Inner2 super class Inner is nested within Outer, not a

If this was made legal, would you still have a problem? Conceptually,
it seems fine to me that a subclass of an inner class should inherit
its access to the outer class. Certainly if this wasn't intended, a
class designer could specify "final" on the original inner class.

class WindowManager {  class Window {}  }
class ToolWindow : WindowManager.Window { }

(BTW: I thought window managers governed windows, not owned them?
Also, a button is a kind of window :)


> I don't see why it shouldn't be, theoretically. Though I also don't know
> what the syntax is (or would be). It doesn't seem to be possible at all
> right now.

Getting the existing rule relaxed might be easier than getting new
syntax implemented.


David.

>
> > Regan
>
> --downs
>



More information about the Digitalmars-d mailing list