From: "Jeffrey R. Carter" <spam.not.jrcarter@acm.not.spam.org>
Subject: Re: Constant record components
Date: Sat, 01 Jul 2006 21:44:09 GMT
Date: 2006-07-01T21:44:09+00:00 [thread overview]
Message-ID: <J0Cpg.1052504$xm3.347020@attbi_s21> (raw)
In-Reply-To: <1151778788.25270.4.camel@localhost.localdomain>
Georg Bauhaus wrote:
> On Sat, 2006-07-01 at 10:37 -0700, ME wrote:
>
>> What I meant was components that can not be changed after the record
>> components are initialized.
>
> package rec is
> type R is tagged private;
>
> function make(m: INTEGER) return R;
> -- `m` is the initial value for the immutable component
>
> function immutable(thing: R) return INTEGER;
> private
...
> end rec;
A : Rec.R := Rec.Make (1);
Y : Integer;
X : constant Integer := Rec.Immutable (A);
begin
A := Rec.Make (2);
Y := Rec.Immutable (A);
if X = Y then
Ada.Text_IO.Put_Line ("Component is constant");
else
Ada.Text_IO.Put_Line ("Component is not constant");
end if;
You get 3 guesses which string is output, and the 1st 2 don't count.
Clearly, this does not meet the OP's interest in components that cannot
be changed after initialization.
--
Jeff Carter
"When danger reared its ugly head, he bravely
turned his tail and fled."
Monty Python and the Holy Grail
60
next prev parent reply other threads:[~2006-07-01 21:44 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <12ad8guf3sg1o0d@corp.supernews.com>
2006-07-01 17:06 ` Constant record components Dmitry A. Kazakov
2006-07-01 17:37 ` ME
2006-07-01 18:33 ` Georg Bauhaus
2006-07-01 21:44 ` Jeffrey R. Carter [this message]
2006-07-02 9:18 ` Georg Bauhaus
2006-07-02 16:13 ` ME
2006-07-03 7:50 ` Dmitry A. Kazakov
2006-07-03 11:46 ` Craig Carey
2006-07-04 0:06 ` M E Leypold
2006-07-03 16:31 ` ME
2006-07-03 23:53 ` Randy Brukardt
2006-07-04 1:59 ` Craig Carey
2006-07-04 7:25 ` ME
2006-07-05 21:55 ` Randy Brukardt
2006-07-06 0:59 ` tmoran
2006-07-06 7:47 ` Jean-Pierre Rosen
2006-07-06 22:29 ` Randy Brukardt
2006-07-07 4:34 ` Jeffrey R. Carter
2006-07-07 5:39 ` ME
2006-07-07 9:15 ` Georg Bauhaus
2006-07-08 16:13 ` ME
2006-07-08 17:14 ` Georg Bauhaus
2006-07-13 6:58 ` ME
2006-07-13 8:39 ` Georg Bauhaus
2006-07-07 21:04 ` Randy Brukardt
2006-07-14 8:15 ` Craig Carey
2006-07-14 12:51 ` Craig Carey
2006-07-15 3:45 ` ME
2006-07-04 0:08 ` M E Leypold
2006-07-02 5:52 ` Craig Carey
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox