From: fjh@cs.mu.oz.au (Fergus Henderson)
Subject: Re: local variables
Date: 1998/04/13
Date: 1998-04-13T00:00:00+00:00 [thread overview]
Message-ID: <6gtkne$crh$1@mulga.cs.mu.OZ.AU> (raw)
In-Reply-To: dewar.892262465@merv
dewar@merv.cs.nyu.edu (Robert Dewar) writes:
>Instead you can just introduce a nested package:
>
> package body Abstraction is
> procedure Op1(...) is
> begin
> -- do something interesting
> end Op1;
>
> package body Encapsulate is
>
> Counter : Integer := 0; -- "static" variable used by Bump_Counter
> procedure Bump_Counter(Next : out Integer) is
> begin
> Counter := Counter + 1;
> Next := Counter;
> end Bump_Counter;
> end Encapsulate;
> end Abstraction;
>
>
>The corresponding package spec might have
>
> package Abstraction is
> procedure Op1(...);
>
> package Encapsulate is
> procedure Bump_Counter (Next : out Integer);
> end Encapsulate;
>
> procedure Bump_Counter (Next : out Integer)
> renames Encapsulate.Bump_Counter;
>
> end Abstraction;
There's no need to put the package `Encapsulate' in the package
spec rather than the package body, is there?
I'd write this as
package Abstraction is
procedure Op1(...);
procedure Bump_Counter (Next : out Integer);
end Abstraction;
package body Abstraction is
procedure Bump_Counter (Next : out Integer)
renames Encapsulate.Bump_Counter;
package Encapsulate is
procedure Bump_Counter (Next : out Integer);
end Encapsulate;
package body Encapsulate is
-- as above
end Encapsulate;
procedure Bump_Counter (Next : out Integer);
renames Encapsulate.Bump_Counter;
end Abstraction;
--
Fergus Henderson <fjh@cs.mu.oz.au> | "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh> | of excellence is a lethal habit"
PGP: finger fjh@128.250.37.3 | -- the last words of T. S. Garp.
next prev parent reply other threads:[~1998-04-13 0:00 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
1998-04-10 0:00 local variables B.Voh
1998-04-10 0:00 ` Tucker Taft
1998-04-10 0:00 ` Robert Dewar
1998-04-13 0:00 ` Fergus Henderson [this message]
1998-04-10 0:00 ` Niklas Holsti
1998-04-10 0:00 ` Simon Wright
1998-04-10 0:00 ` Robert Dewar
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox