comp.lang.ada
 help / color / mirror / Atom feed
* Private function w/ Tagged return-type.
@ 2013-07-29 20:54 Shark8
  2013-07-29 21:20 ` Adam Beneschan
  0 siblings, 1 reply; 3+ messages in thread
From: Shark8 @ 2013-07-29 20:54 UTC (permalink / raw)


Given the following:

with Ada.Streams;
package example is
    Type Subject is tagged private;
    function Create return Subject;
private
        function Input(
		    Stream : not null access Ada.Streams.Root_Stream_Type'Class)
	return  Subject is (Create);

---- private, moved here, will work.
    
    Type Subject is tagged null record
      with Input => Input;

    function Create return Subject is (null record);
end example;

yields the following error message:
     private function with tagged result must override visible-part function
     move subprogram to the visible part (RM 3.9.3(10))

Yet, the given paragraph says:
   For an abstract type declared in a visible part, an abstract primitive subprogram shall not be declared in the private part, unless it is overriding an abstract subprogram implicitly declared in the visible part. For a tagged type declared in a visible part, a primitive function with a controlling result or a controlling access result shall not be declared in the private part, unless it is overriding a function implicitly declared in the visible part.

Is the error correct? 'Input, 'Output, 'Read & 'Write are implicitly created due to the stream operations/attributes, though arguably they are not functions/subprograms.

I should think that it would be perfectly appropriate to place the declarations of the functions you're assigning to 'Read/'Write/'Input/'Output into the private portion of the package.

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

end of thread, other threads:[~2013-07-29 21:27 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-07-29 20:54 Private function w/ Tagged return-type Shark8
2013-07-29 21:20 ` Adam Beneschan
2013-07-29 21:27   ` Adam Beneschan

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