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=0.2 required=5.0 tests=BAYES_00,INVALID_MSGID, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,988f2c34ce3e6595 X-Google-Attributes: gid103376,public From: "Norman H. Cohen" Subject: Re: Modest proposal, 2 of 3 Date: 1996/11/25 Message-ID: <3299FA03.5A1D@watson.ibm.com>#1/1 X-Deja-AN: 200687159 references: <575ag6$rt6@netline-fddi.jpl.nasa.gov> content-type: text/plain; charset=us-ascii organization: IBM Thomas J. Watson Research Center mime-version: 1.0 reply-to: ncohen@watson.ibm.com newsgroups: comp.lang.ada x-mailer: Mozilla 3.0 (Win95; I) Date: 1996-11-25T00:00:00+00:00 List-Id: Van Snyder wrote: > PROPOSAL for next standardization of Ada > > Allow objects to be declared in the public part of a package > specification with mode "out". The meaning is that clients of the > package can reference the variable, but can't store into it. Somewhat confusing since generic formal parameters of mode IN indicate that the generic parameter is to be bound to some constant value, and a subprogram parameter of mode IN is constant within the subprogram body. So perhaps instead of X: out Integer; the notation should be X: Integer constant when not private; -- ;-) > Thus, a variable that a package publishes with "out" mode has the same > properties as a private variable with a public parameterless function to > access it, and no procedure to update it directly. But it's more > efficient, and there's less code to write initially, and therefore less > to read and understand when you're the poor schmo assigned to make the > next minor change. The effect of an object modifiable as a variable from within a package, but only readable as a constant from outside the package, can already be achieved in Ada 95 as follows: package P is type Access_Constant is access constant Integer; Constant_View_Of_Variable: constant Access_Constant; private Variable: aliased Integer; Constant_View_Of_Variable: constant Access_Constant := Variable'Access; end P; Of course this doesn't quite achieve the referential transparency Van Snyder is after, because it requires you to say Constant_View_Of_Variable.all instead of Constant_View_Of_Variable. -- Norman H. Cohen mailto:ncohen@watson.ibm.com http://www.research.ibm.com/people/n/ncohen