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: "Samuel T. Harris" Subject: Re: private type discriminants ignored? Date: 1998/04/28 Message-ID: <35468F93.C371940@hso.link.com>#1/1 X-Deja-AN: 348601857 Content-Transfer-Encoding: 7bit References: <35460201.ED1315C4@hso.link.com> <354612AF.41C6@hso.link.com> Content-Type: text/plain; charset=us-ascii Organization: Raytheon Training Inc. Mime-Version: 1.0 Newsgroups: comp.lang.ada Date: 1998-04-28T00:00:00+00:00 List-Id: Patrick D. Rogers wrote: > > 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 To one-up the pedantic theme :) Bob's "... unconstrained variable" appears several lines after "a default means that the discriminant can change". Perhaps I should have said "Not entirely complete." Bob covers unconstrained variables exclusively. I simply sought to cover constrained variables and complete the picture. The subtle differences are lost on many of our (my company's) Ada initiates and I have spent some time explaining the nuances of this construction, especially as applied to polymorphic variant records. Now, how's that for a recovery ;) -- Samuel T. Harris, Principal Engineer Raytheon Training Incorporated "If you can make it, We can fake it!"