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=unavailable autolearn_force=no version=3.4.4 Path: border2.nntp.dca3.giganews.com!backlog4.nntp.dca3.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!ottix-news.ottix.net!newsswitch.lcs.mit.edu!nntp.TheWorld.com!.POSTED!not-for-mail From: Robert A Duff Newsgroups: comp.lang.ada Subject: Re: Strange error message Date: Sun, 01 Jun 2014 17:18:03 -0400 Organization: The World Public Access UNIX, Brookline, MA Message-ID: References: <33e17033-615d-43d4-8b47-9357c8875a10@googlegroups.com> NNTP-Posting-Host: shell01.theworld.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: pcls7.std.com 1401657475 5024 192.74.137.71 (1 Jun 2014 21:17:55 GMT) X-Complaints-To: abuse@TheWorld.com NNTP-Posting-Date: Sun, 1 Jun 2014 21:17:55 +0000 (UTC) User-Agent: Gnus/5.1008 (Gnus v5.10.8) Emacs/21.3 (irix) Cancel-Lock: sha1:eEuQ5C4YzdEf5QUnvPg4adPmtKc= X-Original-Bytes: 3425 Xref: number.nntp.dca.giganews.com comp.lang.ada:186697 Date: 2014-06-01T17:18:03-04:00 List-Id: Charly writes: > Hi, > > when I defined a class hierarchy I encountered a problem, that I could reduce > to the following few lines: > > This version compiles without problems: > ----------------- > package Test is > > type Base is tagged private; > function Create return Base; > > type High is new Base with private; > > private > > type Base is tagged null record; > > type High is new Base with null record; > > end Test; > ----------------- > > but this one > > ----------------- > package Test is > > type Base is tagged private; > function Create return Base; > > type High is new Base with private; > > private > > type Base is tagged null record; > > type High is new Base with record -- > H_Val : Natural := 0; -- these lines are changed > end record; -- > > end Test; > ----------------- > > does not compile an I get an error: > > type must be declared abstract or "Create" overridden > > Why do I have to overide the function Create for type High. > I don't see the necessity. Because whatever Create does, it doesn't set any value for H_Val, because H_Val doesn't exist in Base. So it makes no sense to inherit it as is. [*] But see below. In your first version, High adds no new components. Ada 95 used to require overriding in that case, too, but the overriding is always: function Create return High is begin return (Base with null record); end Create; What else would it be? So the language was changed to provide that overriding by default in the "null record" case. I don't know why Dmitry and Randy want us to write that out explicitly; it seems like an obviously useful and safe default. [*] Your H_Val has a default of 0, so it might make sense to define the language to provide an automatic default overriding: function Create return High is begin return (Base with H_Val => 0); end Create; That's not how the language is now, and I suspect Dmitry and Randy would be appalled at the idea. I don't really understand their point of view -- I mean, I love consistency and all, but "A FOOLISH consistency is the hobgloblin... etc". By the way, Tucker wanted the current rule for Ada 95. I argued him out of it. That is, in 1993 or so, I agreed with Dmitry's and Randy's current position. I've since changed my mind. - Bob