comp.lang.ada
 help / color / mirror / Atom feed
From: "Randy Brukardt" <randy@rrsoftware.com>
Subject: Re: Functions vs constants
Date: Tue, 22 Jul 2014 17:07:55 -0500
Date: 2014-07-22T17:07:55-05:00	[thread overview]
Message-ID: <lqmnbr$j13$1@loke.gir.dk> (raw)
In-Reply-To: cso9nzjs6q5q$.16o96j9yv70q1$.dlg@40tude.net


"Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> wrote in message 
news:cso9nzjs6q5q$.16o96j9yv70q1$.dlg@40tude.net...
> On Mon, 21 Jul 2014 18:23:05 -0500, Randy Brukardt wrote:
>
>> Otherwise, I think all objects (including exceptions) should allow
>> overloading.
>
> What would be of exception renaming then? Would it create a new, possibly,
> overloaded with itself object? That would be fun!

??? I don't see a problem. Resolution works as it does now for subprograms, 
and either there is a unique resolution or not. No one says "what would be 
of function renaming if overloading is allowed" -- it just is and everything 
is fine.

The primary reason for allowing overloading of exceptions (as with objects) 
is so that they don't get hidden by something unrelated. (Especially a 
problem for use clauses.) If you have something like (assume these 
declarations have real names and the packages contain dozens of declarations 
each):

   package P is
       Error : Boolean;
   end P;
   package Q is
       Error : exception;
   end Q;

   with P, Q; use P, Q;
   procedure R is
   begin
       if Error then -- (1)
          raise Error; -- (2)
      end if;
   end R;

both (1) and (2) are illegal today. But there's no good reason for that; the 
profiles (imagining an extended idea of profile to include objects and 
exceptions) are different and there can be no more confusion between them 
than between overloaded enumeration literals.

If you've got entities with the same names and profiles in different 
packages, that's a problem that should be detected. But so long as the 
profiles are different (and that's almost always the case), then there 
shouldn't be a problem (which is not the case today).

A thought just popped into my head, perhaps you are worrying about:
    Name_Error : exception renames IO_Exceptions.Name_Error;
This is thought by many to be a long time bug in Ada. If you have "use 
Text_IO, IO_Exceptions;" then "raise Name_Error;" is illegal -- but that's 
silly because both possibilities are the same entity.

That could be fixed by adopting a rule such that if the only reason that a 
name is ambiguious is because it resolved to several different views of the 
same entity, that it would be treated as properly resolved to the entity. 
The only thing the compiler (or reader, for that matter) need care about is 
underlying entity, not exactly which view is involved. That would be 
additional complication in the language rules, but an Ada programmer would 
almost never care about it.

In any case, this isn't necessary to support object and exception 
overloading; it would help some, but more importantly it's probably a good 
idea on its own.

                                    Randy.


  reply	other threads:[~2014-07-22 22:07 UTC|newest]

Thread overview: 47+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-21 21:18 Functions vs constants Victor Porton
2014-07-21 21:28 ` Victor Porton
2014-07-21 21:49   ` Shark8
2014-07-21 21:52     ` Victor Porton
2014-07-21 21:59       ` Adam Beneschan
2014-07-21 21:35 ` Niklas Holsti
2014-07-21 21:41   ` Victor Porton
2014-07-21 23:23   ` Randy Brukardt
2014-07-22  7:42     ` Dmitry A. Kazakov
2014-07-22 22:07       ` Randy Brukardt [this message]
2014-07-23  7:55         ` Dmitry A. Kazakov
2014-07-23 21:44           ` Randy Brukardt
2014-07-23 12:37         ` G.B.
2014-07-23 22:12           ` Randy Brukardt
2014-07-24  7:20             ` Stefan.Lucks
2014-07-25  4:43               ` Randy Brukardt
2014-07-26  2:36                 ` Shark8
2014-07-24  8:27             ` Georg Bauhaus
2014-07-24 10:11               ` Dmitry A. Kazakov
2014-07-24 10:49                 ` G.B.
2014-07-24 12:50                   ` Dmitry A. Kazakov
2014-07-25  4:56               ` Randy Brukardt
2014-07-25  6:45                 ` Georg Bauhaus
2014-07-25 10:46                   ` G.B.
2014-07-25 19:31                   ` Randy Brukardt
2014-07-25 20:02                     ` Dmitry A. Kazakov
2014-07-26  2:45                       ` Shark8
2014-07-26  8:02                         ` Dmitry A. Kazakov
2014-07-26 14:03                           ` Shark8
2014-07-26 14:18                             ` Dmitry A. Kazakov
2014-07-21 21:55 ` Victor Porton
2014-07-22  7:06 ` Maciej Sobczak
2014-07-22  7:50   ` Dmitry A. Kazakov
2014-07-22 22:14     ` Randy Brukardt
2014-07-23 13:21       ` Stephen Leake
2014-07-23 13:27         ` Victor Porton
2014-07-23 15:10         ` Adam Beneschan
2014-07-23 21:57 ` Robert A Duff
2014-07-24 12:25   ` Victor Porton
2014-07-24 15:53     ` Robert A Duff
2014-07-24 15:57       ` Victor Porton
2014-07-24 16:47   ` Pascal Obry
2014-07-24 12:26 ` anon
2014-07-24 12:52 ` Victor Porton
2014-07-24 16:01   ` Robert A Duff
2014-07-24 16:15     ` Adam Beneschan
2014-07-25  5:05     ` Randy Brukardt
replies disabled

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