comp.lang.ada
 help / color / mirror / Atom feed
From: Adam Beneschan <adambeneschan@aol.com>
Subject: Re: Private function w/ Tagged return-type.
Date: Mon, 29 Jul 2013 14:20:24 -0700 (PDT)
Date: 2013-07-29T14:20:24-07:00	[thread overview]
Message-ID: <64498c9c-7add-4b4e-a592-51e12e1aeba6@googlegroups.com> (raw)
In-Reply-To: <56e81849-4303-4a78-878c-fff8b57ce64f@googlegroups.com>

On Monday, July 29, 2013 1:54:40 PM UTC-7, Shark8 wrote:
> 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.

Well, no matter which way you argue, the T'Input function does not have the name "Input" and will not be overridden by a function named "Input".

You can put your Input function in a nested package to avoid the error, since that will make it non-primitive.

                                 -- Adam

  reply	other threads:[~2013-07-29 21:20 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-29 20:54 Private function w/ Tagged return-type Shark8
2013-07-29 21:20 ` Adam Beneschan [this message]
2013-07-29 21:27   ` Adam Beneschan
replies disabled

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