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-Thread: 103376,34257fd17abeba14 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newscon06.news.prodigy.com!prodigy.net!newsfeed-00.mathworks.com!nntp.TheWorld.com!not-for-mail From: Robert A Duff Newsgroups: comp.lang.ada Subject: Re: [SPARK] Code safety and information hiding Date: 18 Aug 2006 19:02:20 -0400 Organization: The World Public Access UNIX, Brookline, MA Message-ID: References: NNTP-Posting-Host: shell01.theworld.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: pcls4.std.com 1155942140 4897 192.74.137.71 (18 Aug 2006 23:02:20 GMT) X-Complaints-To: abuse@TheWorld.com NNTP-Posting-Date: Fri, 18 Aug 2006 23:02:20 +0000 (UTC) User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2 Xref: g2news2.google.com comp.lang.ada:6263 Date: 2006-08-18T19:02:20-04:00 List-Id: "Jeffrey R. Carter" 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