comp.lang.ada
 help / color / mirror / Atom feed
From: Robert A Duff <bobduff@shell01.TheWorld.com>
Subject: Re: [SPARK] Code safety and information hiding
Date: 18 Aug 2006 19:02:20 -0400
Date: 2006-08-18T19:02:20-04:00	[thread overview]
Message-ID: <wccoduhy7er.fsf@shell01.TheWorld.com> (raw)
In-Reply-To: gFKEg.138542$1i1.49988@attbi_s72

"Jeffrey R. Carter" <spam.not.jrcarter@acm.not.spam.org> writes:

> [Aside: I really don't like the use of the term "global" for state
> variables. True global variables (in package specs) should be illegal;
> state variables are a different cup of fish and should not be tainted by
> the "global" label.]

I think the terms "global" and "local" are most useful if they are
relative to something.  A variable can be more global or less global.
The Ada RM agrees with that (not surprising, since I wrote
that part ;-)).  See quote below.

Jeff wants to consider package-spec variables particularly evil.
OK, but there are global variables even more global than that.
The Registry in windows is an obnoxiously global variable.
And environment variables under many operating systems are
obnoxiously global.  I suppose disk files are global, although
I don't usually find them obnoxious.

I don't agree that package-spec variables should be illegal.  Such a
rule accomplishes nothing, since the programmer can just have a getter
and a setter, which is just as evil.  In some rare cases, a package-spec
variable makes sense, and in those cases, the getter/setter method is no
better (just more verbose).

So I like the SPARK syntax for "global".  It means so-and-so variable is
global to this procedure, not necessarily global to the whole program,
or global to that part of the program that with's certain package, or
global to the whole world.

AARM-8.1 says:

14    [{local to} A declaration is local to a declarative region if the
declaration occurs immediately within the declarative region.] [An entity is
local to a declarative region if the entity is declared by a declaration that
is local to the declarative region.]

    14.a  Ramification: "Occurs immediately within" and "local to" are
          synonyms (when referring to declarations).

    14.b  Thus, "local to" applies to both declarations and entities, whereas
          "occurs immediately within" only applies to declarations. We use
          this term only informally; for cases where precision is required, we
          use the term "occurs immediately within", since it is less likely to
          cause confusion.

15    {global to} A declaration is global to a declarative region if the
declaration occurs immediately within another declarative region that encloses
the declarative region. An entity is global to a declarative region if the
entity is declared by a declaration that is global to the declarative region.

- Bob



  parent reply	other threads:[~2006-08-18 23:02 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-08-16  7:56 [SPARK] Code safety and information hiding Maciej Sobczak
2006-08-16  8:53 ` roderick.chapman
2006-08-16 11:18   ` Stuart
2006-08-16 13:23     ` Maciej Sobczak
2006-08-16 19:49 ` [SPARK] " Jeffrey R. Carter
2006-08-17  7:01   ` Maciej Sobczak
2006-08-17 18:08     ` Jeffrey R. Carter
2006-08-17 20:00       ` Björn Persson
2006-08-18  1:22         ` Jeffrey R. Carter
2006-08-18 19:39           ` Björn Persson
2006-08-19  5:35             ` Jeffrey R. Carter
2006-08-19 12:47               ` Björn Persson
2006-08-20  3:58                 ` Jeffrey R. Carter
2006-08-20 11:35                   ` Björn Persson
2006-08-18 23:02   ` Robert A Duff [this message]
2006-08-19  5:40     ` Jeffrey R. Carter
2006-08-19  9:49       ` Stephen Leake
2006-08-20  3:52         ` Jeffrey R. Carter
2006-08-20 19:06           ` Stephen Leake
2006-08-21  1:07             ` Jeffrey R. Carter
2006-08-21  7:25               ` Maciej Sobczak
2006-08-21 19:31                 ` Jeffrey R. Carter
2006-08-21 19:58                   ` Dmitry A. Kazakov
2006-08-21 21:06                     ` Björn Persson
2006-08-22  7:16                       ` Maciej Sobczak
2006-08-22  9:45                         ` Björn Persson
2006-08-22 12:42                           ` Maciej Sobczak
2006-08-22  7:27                       ` Dmitry A. Kazakov
2006-08-21 11:30             ` Colin Paul Gloster
2006-08-22 10:51               ` Stephen Leake
2006-08-23  9:44     ` Peter Amey
2006-08-23 22:37       ` Jeffrey R. Carter
2006-08-24 10:55         ` Peter Amey
2006-08-24 23:33           ` Jeffrey R. Carter
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox