TEAM-ADA Archives

Team Ada: Ada Programming Language Advocacy

TEAM-ADA@LISTSERV.ACM.ORG

Options: Use Forum View

Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Subject:
From:
Pascal Obry <[log in to unmask]>
Reply To:
Pascal Obry <[log in to unmask]>
Date:
Mon, 7 Dec 1998 09:56:20 +0100
Content-Type:
text/plain
Parts/Attachments:
text/plain (60 lines)
> -----Message d'origine-----
> De:   Coniam, Todd (MSgt) [SMTP:[log in to unmask]]
> Date: vendredi 4 decembre 1998 18:09
> A:    [log in to unmask]
> Objet:        Re: Static variables in Ada
>
> I would say make an inner package, called STATIC, that
> holds all static variables.  Then use a renames clause
> in each subprogram of the outer package to get a direct
> simple name visibility.
>
> Example:
>
> Package body Bar is
>
>    Package Static is
>       Foo_V : integer;  -- that way we can have other V's
>       ...
>    End Static;
>    ...
>    Function Foo return Integer is
>       V : Integer renames Static.Foo_V;
>    Begin
>       V := Init_Static;
>       ...
>    End Foo;
>
> End Bar;
>
> The only disadvantage I see is that you have to
> change the type name in two places (Static, Foo)
> if it ever needs to change.

I really don't like this solution because Foo_V is usable by others procedures
or functions
in Bar package. And this is another disadvantage !

The best solution seem to be the package Outer/Inner provided by Mark
Lundquist. In this
example only one function (or a set of function declared in Inner) could access
the "static"
variable.

Pascal.

--|------------------------------------------------------------
--| Pascal Obry                               Team-Ada Member |
--|                                                           |
--| EDF-DER-IPN-SID- T T I                                    |
--|                       Intranet: http://cln46gb            |
--| Bureau N-023            e-mail: [log in to unmask]     |
--| 1 Av General de Gaulle  voice : +33-1-47.65.50.91         |
--| 92141 Clamart CEDEX     fax   : +33-1-47.65.50.07         |
--| FRANCE                                                    |
--|------------------------------------------------------------
--|
--|   http://ourworld.compuserve.com/homepages/pascal_obry
--|
--|   "The best way to travel is by means of imagination"

ATOM RSS1 RSS2