From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 Path: border2.nntp.dca1.giganews.com!border1.nntp.dca1.giganews.com!nntp.giganews.com!newspeer1.nac.net!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!rt.uk.eu.org!aioe.org!.POSTED!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: Functions vs constants Date: Wed, 23 Jul 2014 09:55:19 +0200 Organization: cbb software GmbH Message-ID: <6iqu3i2wgq5t$.166jyq7d1w1nc.dlg@40tude.net> References: Reply-To: mailbox@dmitry-kazakov.de NNTP-Posting-Host: ot/DC7n2aCvt5pcTM4dZCw.user.speranza.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@aioe.org User-Agent: 40tude_Dialog/2.0.15.1 X-Notice: Filtered by postfilter v. 0.8.2 Xref: number.nntp.dca.giganews.com comp.lang.ada:187802 Date: 2014-07-23T09:55:19+02:00 List-Id: On Tue, 22 Jul 2014 17:07:55 -0500, Randy Brukardt wrote: > "Dmitry A. Kazakov" 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. I thought about overloading exceptions with exceptions. Presently exceptions are perceived as a kind of literals rather than objects. It is untrue, but that is the desired semantics of [OK, some wanted C++ alike semantics but that is another story]. Renaming conflicts with this. Overloading may further erode the model. > 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; Yes. It does not make sense. > 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. Yes. > 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. Right. But also that renaming were not allowed to create any objects. That would break a lot of exiting code, but this code is already broken, IMO. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de