Once Again, Feature Request: Nested classes in separate scope

downs default_357-line at yahoo.de
Tue Nov 6 02:29:11 PST 2007


Regan Heath wrote:
> downs wrote:
>> Vladimir Panteleev wrote:
>>> I think this could be done with the announced "alias foo this;" syntax.
>>> (just declare a Foo in Bar and import its namespace)
>>>
>>
>> Yes, but part of the point of the proposal is to avoid using the has-a
>> relationship in situations where it's inadequate or flat out wrong (the
>> Window doesn't own the WindowManager, it's the other way around). Sorry
>> if I'm misunderstanding an OO concept here.
> 
> Isn't this the same modal as you often see in UI code, where a window
> "has a" parent window.  The parent window could be said to own the child
> window but the child still "has a" parent.
> 
> I'm not sure "has a" necessarily implies ownership, this may be the
> point which is bothering you?
> 
> I have a home, but my landlord owns it.
> 
> I have a job, but I dont own any shares in the compay.
> 
> ...
> 
> Regan

Fair.
Okay, let's drop the ownership debate and reformulate the problem to
expressing that class Bar exists in the _context_ of class Foo.
I agree that this relationship could be modelled by "class Foo { Bar
context; alias context this; " as proposed before, but isn't this
exactly what nested classes are supposed to be? Things that only exist
in the context of something else? I simply think it would be better to
extend this existing feature to allow Foo to be in a separate scope from
Bar, instead of using what essentially amounts to a workaround.
Nonetheless, thanks for your reply. :)
 --downs



More information about the Digitalmars-d mailing list