comp.lang.ada
 help / color / mirror / Atom feed
From: Victor Porton <porton@narod.ru>
Subject: Bad influence of private part on what subprograms can be defined
Date: Mon, 09 Oct 2017 01:52:03 +0300
Date: 2017-10-09T01:52:03+03:00	[thread overview]
Message-ID: <orea6h$1fva$1@gioia.aioe.org> (raw)

The following does not compile:

$ gnatmake -gnat2012 test
gcc-7 -c -gnat2012 test.adb
test.adb:18:20: subprogram "X" overrides inherited operation at line 21
gnatmake: "test.adb" compilation error


-- test.adb
procedure Test is

  package A is
    type A_Type is tagged null record;
    not overriding procedure X(Object: A_Type);
  end;

  package body A is
    procedure X(Object: A_Type) is
    begin
      null;
    end;
  end;

  package B is
    type B_Type is tagged private;
    not overriding procedure X(Object: B_Type);
  private
--     type B_Type is tagged null record;
    type B_Type is new A.A_Type with null record;
  end;

  package body B is
    procedure X(Object: B_Type) is
    begin
      null;
    end;
  end;

begin
  null;
end;


So private part badly influences what can and what can and what cannot be 
done in the public part. Private must be private!

Also note that if we would not use "not overriding" then changing the 
ancestor in the private part would have the potential to influence semantics 
of the program! (not in the above code as both procedures X are null, but in 
principle)

Can anything be done around this issue?

One possible solution is to allow "not overriding" (and behave as if it is 
not overriding) in public part even if it is considered overridable 
accordingly the private part (but not public part). This would make some 
non-compilable programs compilable, bit would not change semantic of 
compilable programs. So this is viable.

Really bad!

-- 
Victor Porton - http://portonvictor.org

             reply	other threads:[~2017-10-08 22:52 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-08 22:52 Victor Porton [this message]
2017-10-09  7:25 ` Bad influence of private part on what subprograms can be defined Dmitry A. Kazakov
2017-10-09  9:25   ` AdaMagica
2017-10-09 10:19     ` AdaMagica
2017-10-09 22:02 ` 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