comp.lang.ada
 help / color / mirror / Atom feed
From: Adam Beneschan <adam@irvine.com>
Subject: Re: When is a rename not a rename?
Date: Fri, 1 Feb 2013 17:40:40 -0800 (PST)
Date: 2013-02-01T17:40:40-08:00	[thread overview]
Message-ID: <18239154-6753-455c-b00e-4caf876e03ff@googlegroups.com> (raw)
In-Reply-To: <8f7b509f-c92d-48b0-8322-cdc48baf4846@googlegroups.com>

On Friday, February 1, 2013 10:31:06 AM UTC-8, ytomino wrote:
> How is my previous post?
> 
> First,
> 
> package XXX is
>    type T is private;
>    function "=" (Left, Right : T) return Boolean;
> end XXX;
> 
> declare
>    use XXX;
>    use type T;
>    A, B : T;
> begin
>    if A = B then -- legal
> 
> Then, ready new package YYY renaming XXX.
> 
> with XXX;
> package YYY is
>    subtype T is XXX.T;
>    function "=" (Left, Right : T) return Boolean renames XXX."=";
> end YYY;
> 
> And, replace.
> 
> declare
>    use YYY; -- change here
>    use type T;
>    A, B : T;
> begin
>    if A = B then -- error !!

I can understand why this would be annoying.  It seems like a problem.  I don't know if it's enough of a problem to consider fixing the language.  It wouldn't be trivial.  Perhaps 8.6(30) could be modified to add some concept of two acceptable interpretations that are essentially the same because the usage names end up denoting the same entity via renaming.  It seems hard to get the wording right.  Plus you have to deal with things like this:

package XXX is
   type T is private;
   procedure Operation (Obj : in out T; Offset : Integer := 0);
end XXX;

package YYY is
   subtype T renames XXX.T;
   procedure Operation (Obj : in out T; Offset : Integer := -1) 
       renames XXX.Operation;
end YYY;

...
use YYY;
use type T;
Z : T;

Operation(Z);

Although the two Operation's that could be denoted by this actually refer to the same declaration after renaming is considered, it's still ambiguous since we don't know what should be passed for Offset.  Parameter names can also be different in a subprogram rename, which can pose another problem.  The language rules would have to be written to allow the case you're interested in but disallow examples like mine.  Not easy.

                            -- Adam



  reply	other threads:[~2013-02-02  1:40 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-29  1:24 When is a rename not a rename? Adam Beneschan
2013-01-30  0:28 ` Randy Brukardt
2013-01-30  0:52   ` Adam Beneschan
2013-01-30  9:31     ` Dmitry A. Kazakov
2013-01-30 14:35       ` ytomino
2013-02-01 10:44 ` Ada novice
2013-02-01 11:27   ` Dmitry A. Kazakov
2013-02-01 17:32     ` Adam Beneschan
2013-02-01 18:31       ` ytomino
2013-02-02  1:40         ` Adam Beneschan [this message]
2013-02-02 12:24           ` ytomino
2013-02-02 14:26           ` Robert A Duff
2013-02-02 17:11             ` Shark8
2013-02-02  0:42       ` Brian Drummond
2013-02-02 11:43         ` AdaMagica
2013-02-03 11:50           ` Brian Drummond
2013-02-03 12:16             ` AdaMagica
2013-02-05  9:53       ` Ada novice
2013-02-01 17:48     ` Ada novice
replies disabled

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