On Jan 21, 2008 12:05 PM, John Stoneham <[EMAIL PROTECTED]> wrote:
> On Jan 21, 2008 1:05 AM, Vinzent Hoefler <[EMAIL PROTECTED]> wrote:
> > On Friday 18 January 2008 20:12, John Stoneham wrote:
>
> Perhaps that's true with regard to name resolution, but Ada's package
> system has a significant feature which Pascal's module system lacks:
> child packages. Conceptually, a child package is the same thing as a
> nested package:
>
> package Parent is
> ...
>    package Child is
>    ...
>    end Child;
> ...
> end Parent;

this looks exactly like Java inner classes.

>
> Now, the nested "Child" can be referenced outside "Parent" as
> "Parent.Child".

java :

org.freepascal.example.OuterClass.InnerClass

defined in a file called "OuterClass.java"

> This has much more to offer than simply another level
> (sometimes very necessary) of organization to a complex program.

yes.

among other things, in the java world, it makes for a great way to be
able to encapsulate and control dependent objects that belong to the
implementation that encapsulates them.

data structure like classes for example that really don't have any
business outside of the parent class.

and even if those child classes are intended to escape out of the
parent class via a return type, it still keeps the namespace and file
system much cleaner, again, where the child has no other general use
in the application.

> For
> example, the private part of a child package has access to it's
> parent's private members as well. The visibility rules are similar to
> those that relate to inheritance (via private, protected, and public
> sections). This adds a level of encapsulation that is very desirable
> in a complex program.

yes, this sounds identical to how java does this as well.

FWIW.

Tony

-- 
X-SA user ? 0.5.1 is out !
XData 0.1 for X-SA is out !
http://x-plane.dsrts.com
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply via email to