* Re: recursive with
1998-09-30 0:00 ` Alastair Brady
@ 1998-10-01 0:00 ` David Pando
1998-10-02 0:00 ` Robert I. Eachus
1 sibling, 0 replies; 4+ messages in thread
From: David Pando @ 1998-10-01 0:00 UTC (permalink / raw)
To: Alastair Brady
Alastair Brady wrote:
>
> David Pando wrote:
>
> > I've got an object defined in a package A with a atribute that points to
> > an object defined in a package B, but this object has an atribute that
> > points to the first objetc (Do I make myself clear?)
> > The problem is than I can't compile the packages, because package A
> > needs packege B that needs package A that...
> > Is there any solution, apart from defining the objects in the same
> > package
>
> Cyclic with's are forbidden in Ada as they prevent type checking. Its not
> clear what sort of objects you are referring to... functions/procedures,
> data or types.
>
> For functions and procdures, if you need to make a call back to the package
> which you have been called from, then logically either the current operation
> of the operation you wish to call exists in the wrong package. Either they
> should all exist in the same package (if they are strongly related) or all
> exist in separate packages.
>
> For types, it is common to declare a global 'types' package for types which
> are common to multiple areas of the system, which is basically just a
> package spec which is compiled first, and can then be with'ed by all other
> packages. Similarly this can be done for global data, but strictly speaking
> all data should be encapsulated and accessed using access functions
> ------------------------------------------------------------------------
> Alastair Brady, Software Consultant,
Do you mean C-style ?
The problem is that the package were generated by CADRE, a tool that
builts ADA packages from OMT graphs. Every class is encapsulated in a
package named with the name of the class, and the objects of that class
are of the type Instance. For example, the class foo is in the package
foo, an the object is the type foo.Instance, so I can't encapsulate the
related objects in the same package because the names overlap.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: recursive with
1998-09-30 0:00 ` Alastair Brady
1998-10-01 0:00 ` David Pando
@ 1998-10-02 0:00 ` Robert I. Eachus
1 sibling, 0 replies; 4+ messages in thread
From: Robert I. Eachus @ 1998-10-02 0:00 UTC (permalink / raw)
In article <361272E7.662A074@rol3.com> Alastair Brady <alastair.brady@rol3.com> writes:
> For functions and procdures, if you need to make a call back to the package
> which you have been called from, then logically either the current operation
> of the operation you wish to call exists in the wrong package. Either they
> should all exist in the same package (if they are strongly related) or all
> exist in separate packages.
Good advice.
> For types, it is common to declare a global 'types' package for types which
> are common to multiple areas of the system, which is basically just a
> package spec which is compiled first, and can then be with'ed by all other
> packages. Similarly this can be done for global data, but strictly speaking
> all data should be encapsulated and accessed using access functions
I'll call this dangerous advice, not really wrong. It leads to bad
software engineering if a miscellany of types gets collected in a
single package. When this happens the people on the project complain
about slow Ada compilers and forget to point the finger in the right
place. Get rid of the global package, and you stop generating
problems every time one of the 43 people who think they own a type
make a "slight" change to it.
The only global types package you need should be Standard. (For
example, in doing simulations you need times all over the place. I've
never had problems using Duration for that time type, but I guess it
could happen.)
--
Robert I. Eachus
with Standard_Disclaimer;
use Standard_Disclaimer;
function Message (Text: in Clever_Ideas) return Better_Ideas is...
^ permalink raw reply [flat|nested] 4+ messages in thread