comp.lang.ada
 help / color / mirror / Atom feed
From: Stephen Leake <stephen.a.leake.1@gsfc.nasa.gov>
Subject: Re: Renaming an abstract function
Date: 16 Nov 2001 09:52:59 -0500
Date: 2001-11-16T14:55:28+00:00	[thread overview]
Message-ID: <uvggau5ro.fsf@gsfc.nasa.gov> (raw)
In-Reply-To: 9t1lp1$16unne$1@ID-25716.news.dfncis.de

"Nick Roberts" <nickroberts@adaos.worldonline.co.uk> writes:

> When given the program:
> 
>    package Test1 is
>       type T is abstract tagged limited private;
>       function P (X, Y: in T) return T is abstract;
>       function "*" (A, B: in T) return T renames P; -- error line
>    private
>       type T is abstract tagged limited null record;
>    end;
> 
> GNAT 3.12p on Windows 95 returns the error message:
> 
>    function that returns abstract type must be abstract
> 
> Is this a bug in: (a) GNAT; (b) the RM95; or (c) my brain?

Same error in gnat 3.14 (you should at least upgrade to 3.13p).

RM 8.5.4 (2) says:

  2.      subprogram_renaming_declaration ::=
             subprogram_specification renames callable_entity_name;

The term "callable_entity_name" is not mentioned elsewhere in the
reference manual, which I find odd.

However, just taking the literal English meaning, an abstract function
is _not_ callable, so it appears that you cannot rename an abstract
function. Too bad; it would be nice here (assuming "P" is a
multiplication operator :). 

On the other hand, it could be confusing. Is the renamed function also
inherited (which is what you would want)?

RM 3.2.3 says:

  2. The primitive subprograms of a specific type are defined as
     follows:

       3. The predefined operators of the type, see *Note 4.5::,

       4. For a derived type, the inherited, see *Note 3.4::,
          user-defined subprograms;

       5. For an enumeration type, the enumeration literals (which are
          considered parameterless functions -  see *Note 3.5.1::.);

       6. For a specific type declared immediately within a
          package_specification, any subprograms (in addition to the
          enumeration literals) that are explicitly declared
          immediately within the same package_specification and that
          operate on the type;


I don't think a renaming declaration meets this definition, so they
are not inherited.

So you have to choose either "P" or "*" for the primitive operation,
and provide the other name via renaming as needed for each derived
type. It depends on which name is more likely to be needed.

I guess my answer to your question is (c) :).

-- 
-- Stephe



  reply	other threads:[~2001-11-16 14:52 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-11-15 23:52 Renaming an abstract function Nick Roberts
2001-11-16 14:52 ` Stephen Leake [this message]
2001-11-17  3:08   ` Adam Beneschan
2001-11-17 17:47     ` Egil Harald Hoevik
2001-11-17 18:33     ` Stephen Leake
2001-11-17 22:00     ` Mark Biggar
2001-11-17 23:17       ` Nick Roberts
2001-11-19 15:38       ` Stephen Leake
2001-11-22  3:14         ` Nick Roberts
2001-11-23 15:40           ` Stephen Leake
2001-11-24  3:55             ` Nick Roberts
replies disabled

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