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,FREEMAIL_FROM, WEIRD_PORT autolearn=unavailable autolearn_force=no version=3.4.4 X-Received: by 2002:a24:99c4:: with SMTP id a187-v6mr12205379ite.11.1522182406955; Tue, 27 Mar 2018 13:26:46 -0700 (PDT) X-Received: by 2002:a9d:1f58:: with SMTP id x24-v6mr982012otx.9.1522182406850; Tue, 27 Mar 2018 13:26:46 -0700 (PDT) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!feeder.eternal-september.org!paganini.bofh.team!weretis.net!feeder6.news.weretis.net!feeder.usenetexpress.com!feeder-in1.iad1.usenetexpress.com!border1.nntp.dca1.giganews.com!nntp.giganews.com!u184-v6no5464702ita.0!news-out.google.com!u64-v6ni730itb.0!nntp.google.com!199-v6no5446010itl.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Tue, 27 Mar 2018 13:26:46 -0700 (PDT) Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=2a02:1206:45c6:8b20:98d1:5595:1d10:f801; posting-account=gRqrnQkAAAAC_02ynnhqGk1VRQlve6ZG NNTP-Posting-Host: 2a02:1206:45c6:8b20:98d1:5595:1d10:f801 User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <77e909f6-9f24-4638-ba6a-1872e5a46580@googlegroups.com> Subject: Overriding procedure as null From: gautier_niouzes@hotmail.com Injection-Date: Tue, 27 Mar 2018 20:26:46 +0000 Content-Type: text/plain; charset="UTF-8" Xref: reader02.eternal-september.org comp.lang.ada:51217 Date: 2018-03-27T13:26:46-07:00 List-Id: Hello, I've just come across a little "legal" case that was easy to solve practically, but I'm curious about what is "right" Ada. Consider the following program: with Ada.Streams; procedure test_overriding is type Search_stream is new Ada.Streams.Root_Stream_Type with null record; overriding procedure Read (Stream : in out Search_stream; Item : out Ada.Streams.Stream_Element_Array; Last : out Ada.Streams.Stream_Element_Offset); overriding procedure Write (Stream : in out Search_stream; Item : in Ada.Streams.Stream_Element_Array); -- Implementation of Read & Write: overriding procedure Read (Stream : in out Search_stream; Item : out Ada.Streams.Stream_Element_Array; Last : out Ada.Streams.Stream_Element_Offset) is null; -- Unused overriding procedure Write (Stream : in out Search_stream; Item : in Ada.Streams.Stream_Element_Array) is begin null; -- Something done in real case. end; begin null; end; GNAT (GPL 2017/Win32) compiles seamlessly. ObjectAda (9.2) issues, for the 2nd "Read": test_overriding.adb: Error: line 18 col 24 LRM:8.3(26), Illegal to override declaration in same region, prior declaration is Read at line 7 It looks like OA considers the 2nd occurrence as a specification, not a body - with "is null", it could be both actually. Who's right ? To make both compilers happy I just put the "Read(...) is null" at the first place and remove the 2nd one, so it is only a theory/law problem. More interestingly, if I completely remove the Read procedure, OA still compiles fine and GNAT issues an error (rightfully I think): test_overriding.adb:5:10: type must be declared abstract or "read" overridden test_overriding.adb:5:10: "read" has been inherited from subprogram at a-stream.ads:57 _________________________ Gautier's Ada programming http://www.openhub.net/accounts/gautier_bd