comp.lang.ada
 help / color / mirror / Atom feed
From: Robert A Duff <bobduff@shell01.TheWorld.com>
Subject: Re: GNAT: identifier for stub is not unique
Date: Sun, 18 Nov 2007 18:45:43 -0500
Date: 2007-11-18T18:45:43-05:00	[thread overview]
Message-ID: <wccfxz3aziw.fsf@shell01.TheWorld.com> (raw)
In-Reply-To: aRL_i.184746$Xa3.95692@attbi_s22

"Jeffrey R. Carter" <spam.jrcarter.not@acm.nospam.org> writes:

> braver wrote:
>> How in GNAT can we have two subunits for two overloaded functions with
>> the same name?  What should be they named?
>
> You cannot. This is not a GNAT issue; this restriction is part of the
> language (ARM 10.1.3): "The defining_identifiers of all body_stubs that
> appear immediately within a particular declarative_part shall be
> distinct."

That's right, but you can use renaming to get around this restriction:

package P is
    procedure Overloaded(X: Integer);
    procedure Overloaded(X: Boolean);
end P;

package body P is
    procedure Integer_Op(X: Integer) is separate;
    procedure Boolean_Op(X: Boolean) is separate;

    procedure Overloaded(X: Integer) renames Integer_Op;
    procedure Overloaded(X: Boolean) renames Boolean_Op;
end P;

The "is separate"s are required to have different names, but you can use
overloading in the interface for clients nonetheless, if that's what you
want.

- Bob



  reply	other threads:[~2007-11-18 23:45 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-11-14 23:15 GNAT: identifier for stub is not unique braver
2007-11-14 23:50 ` Jeffrey R. Carter
2007-11-18 23:45   ` Robert A Duff [this message]
2007-11-21 23:05     ` braver
replies disabled

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