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.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,a3471634bf10bf8d X-Google-Attributes: gid103376,public From: "Patrick D. Rogers" Subject: Re: private type discriminants ignored? Date: 1998/04/28 Message-ID: <354612AF.41C6@hso.link.com>#1/1 X-Deja-AN: 348479793 Content-Transfer-Encoding: 7bit References: <35460201.ED1315C4@hso.link.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Organization: NASA, Kennedy Space Center Newsgroups: comp.lang.ada Date: 1998-04-28T00:00:00+00:00 List-Id: Samuel T. Harris wrote: > > Robert A Duff wrote: > > > > In article , > > Jay Sachs wrote: > > > type Stack(Size : Integer := 100) is private; > > > > >... What is the reason that the default initialization > > >seems to be ignored in the discriminant for the private type? > > > > The default isn't being ignored; Size is being correctly initialized to > > 100. However, the mere presence of a default means that the > > discriminant can change. That's confusing, and is a language design > > flaw, IMHO. There should have been a separate keyword or some other > > separate syntax to mean "the discrim might change". But as it is in > > Ada, an unconstrained variable of type Stack can later have a discrim of > > Integer'Last, even though it defaults initially to 100. And many > > compilers take the (quite reasonable) attitude that implicit heap > > allocation is evil, so they allocate the maximum possible size for these > > things. And in this case, that's enormous, and will typically raise > > Storage_Error; hence the warning. > > Not entirely accurate. The mere presense of the default value does > not mean the discriminant can change. It depends on how objects > are declared. Sam, Since we are in pedantic mode, :) Bob said "... unconstrained variable ...", so he is indeed entirely accurate. :) --pat Patrick Rogers