From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII X-Google-Thread: 103376,b7dc7082d345b1e1 X-Google-Attributes: gid103376,public From: "Robert I. Eachus" Subject: Re: package dependence question Date: 2000/06/03 Message-ID: <3939972E.C11E31CA@earthlink.net>#1/1 X-Deja-AN: 630743648 Content-Transfer-Encoding: quoted-printable References: <8gt19i$1cm8@r02n01.cac.psu.edu> X-Accept-Language: en,pdf Content-Type: text/plain; charset=iso-8859-1 X-Complaints-To: abuse@earthlink.net X-Trace: newsread2.prod.itd.earthlink.net 960075473 63.24.57.247 (Sat, 03 Jun 2000 16:37:53 PDT) Organization: The MITRE Corporation MIME-Version: 1.0 NNTP-Posting-Date: Sat, 03 Jun 2000 16:37:53 PDT Newsgroups: comp.lang.ada Date: 2000-06-03T00:00:00+00:00 List-Id: "Antonio Dur=E1n Dom=EDnguez" wrote: = > There are different forms for aproaching to the solution. I think the m= ost > flexible is the object oriented way so that the nodes of the tree are > classes (tagged types) that inherit from a common class. This provides > flexibility (new classes are easily added) and separates the tree handl= ing > from tree-node handling. I think that an even better approach is to use mix-ins. You create a tree type and a node classe in a library package. Then in a nested or child generic package, you create a specific node type that contains an object of the generic formal type: generic type Content is {tagged} {limited} private; {Node_Name: in String;} package Tree.Specific_Node is type New_Node is new Tree.Node with private; generic type Data is private; with procedure Action(Object: in out New_Node; D: in Data); procedure Update(Object: in out New_Node; D: in Data); = private -- overridings go here. = end Tree.Specific_Node; Part of the magic of doing this right is that most of the operations on a node need to be written once, in the proper place--either as an operation of the Node type or of the Content type. The one exception is that operations that change the value of the contents of the node require the addition of a generic instance of Update. If different node types have lots of different update operations, this can begin to get painful, especially if you have to create new record types to collect parameters in.