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.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,754871b84ac2a9be X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 1995-03-08 10:51:51 PST Newsgroups: comp.lang.ada Path: bga.com!news.sprintlink.net!howland.reston.ans.net!gatech!news-feed-1.peachnet.edu!paperboy.wellfleet.com!noc.near.net!inmet!henning!stt From: stt@henning.camb.inmet.com (Tucker Taft) Subject: Re: separate embedded procedures? Message-ID: Sender: news@inmet.camb.inmet.com Organization: Intermetrics, Inc. X-Newsreader: TIN [version 1.1 PL8] References: Date: Wed, 8 Mar 1995 16:32:01 GMT Date: 1995-03-08T16:32:01+00:00 List-Id: Marcel Hawtin (hawtinml@aston.ac.uk) wrote: : Please help me out with this, the Ada books : I've read say that you can declare : a procedure from a package body as separate : and write its body in another file. : Neat idea! So, can I have a procedure body : in a package body that has a couple : of its own nested procedures and declare these procedures separte(ly)? : I've tried, but my complier complains about it. The language requires that the unit immediately enclosing a subunit "stub" must itself be a compilation unit, either a library unit body, or a subunit. : To try to make things clearer : : PACKAGE BODY Blah IS : PROCEDURE Kludged_Mess IS : PROCEDURE Small_Task IS SEPARATE; : BEGIN : : END Kludged_Mess; : END Blah; : In another file, the body of Small_Task : : SEPARATE(Blah) : PROCEDURE Small_Task IS : : END Small_Task; This should work if you first make "Kludged_Mess" into a subunit as well: package body Blah is procedure Kludged_Mess is separate; ... end Blah; separate(Blah) procedure Kludged_Mess is procedure Small_Task is separate; ... end Kludged_Mess; separate(Blah.Kludged_Mess) procedure Small_Task is ... end Small_Task; : Any help greatly appreciated, : Thanks in advance, : Marcel : replies to : hawtinml@aston.ac.uk By the way, in large systems I have found subunits to generally be a pain, as well as nesting of units inside subprograms. In Ada 95 you have the alternative of using child library units for what were subunits of packages. Nesting can generally be avoided by moving the nested unit into the enclosing scope, and giving it explicit parameters rather than having it rely on up-level references. As a side-effect you might discover you have created a potentially reusable chunk of code. By constrast, units nested in a subprogram cannot be reused from outside the subprogram, which is too bad if they do something useful. Pascal tends to encourage nesting, but in Ada, I would recommend avoiding nesting within subprograms. The most easily maintainable Ada systems I have worked on consist of a set of library unit packages, each containing types and corresponding operations. No nesting within subprograms was necessary, except occasionally for nested routines that were so small that they almost qualified as local "macros." -Tucker Taft stt@Inmet.com Intermetrics, Inc.