From: gautier_niouzes@hotmail.com
Subject: Overriding procedure as null
Date: Tue, 27 Mar 2018 13:26:46 -0700 (PDT)
Date: 2018-03-27T13:26:46-07:00 [thread overview]
Message-ID: <77e909f6-9f24-4638-ba6a-1872e5a46580@googlegroups.com> (raw)
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
next reply other threads:[~2018-03-27 20:26 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-27 20:26 gautier_niouzes [this message]
2018-03-28 0:08 ` Overriding procedure as null Randy Brukardt
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox