comp.lang.ada
 help / color / mirror / Atom feed
* Bad influence of private part on what subprograms can be defined
@ 2017-10-08 22:52 Victor Porton
  2017-10-09  7:25 ` Dmitry A. Kazakov
  2017-10-09 22:02 ` Randy Brukardt
  0 siblings, 2 replies; 5+ messages in thread
From: Victor Porton @ 2017-10-08 22:52 UTC (permalink / 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

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2017-10-09 22:02 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-10-08 22:52 Bad influence of private part on what subprograms can be defined Victor Porton
2017-10-09  7:25 ` Dmitry A. Kazakov
2017-10-09  9:25   ` AdaMagica
2017-10-09 10:19     ` AdaMagica
2017-10-09 22:02 ` Randy Brukardt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox