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 X-Google-Thread: a07f3367d7,a41c4a2c795dbe34 X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII Path: g2news1.google.com!news3.google.com!feeder2.cambriumusenet.nl!feeder3.cambriumusenet.nl!feed.tweaknews.nl!193.201.147.78.MISMATCH!feeder.news-service.com!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!feeder2.enfer-du-nord.net!gegeweb.org!aioe.org!.POSTED!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: Will "renames" increase program size? Date: Thu, 16 Jun 2011 14:15:23 +0200 Organization: cbb software GmbH Message-ID: References: <46294109-f07d-49c0-8e81-65a369a05ced@z15g2000prn.googlegroups.com> <1ayjsy885qg2b$.13bmeo97hbau1$.dlg@40tude.net> <316ac8ed-1ded-43d0-98d1-36bb2c0221ad@f2g2000yqh.googlegroups.com> <4bdd2495-fb00-4aa7-89bd-910dfefa3704@i4g2000yqg.googlegroups.com> Reply-To: mailbox@dmitry-kazakov.de NNTP-Posting-Host: FbOMkhMtVLVmu7IwBnt1tw.user.speranza.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 8bit X-Complaints-To: abuse@aioe.org User-Agent: 40tude_Dialog/2.0.15.1 X-Notice: Filtered by postfilter v. 0.8.2 Xref: g2news1.google.com comp.lang.ada:19873 Date: 2011-06-16T14:15:23+02:00 List-Id: On Thu, 16 Jun 2011 03:18:14 -0700 (PDT), AdaMagica wrote: >> procedure Shame is >> � �type T is array (Integer range <>) of Integer; >> � �A : T := (0 => 0, 1 => 1); >> � �subtype S is T (1..2); >> � �B : S renames A; >> begin >> � �Put_Line (Integer'Image (B (0))); -- Surprise, 0 is a legal index of S! >> end Shame; > > Yes, agreed, that's annoying and confusing. Perhaps such a renaming > should be forbidden. Don't know what other consequences such a rule > would have, which other rules would have to be adapted. Think of > generics... (I know you dislike generics.) (:-)) I think it would be difficult to forbid, because renaming that changes view is extremely useful for tagged types. E.g. if X in S'Class then declare Y : S'Class renames S'Class (X); begin I always wished a cleaner and safer construct for this, then we could indeed disable renaming to a view altogether. Luckily, this one is illegal: type T is access all Integer; subtype S is not null T; P1 : T := null; P2 : S renames S (P1); >> Regarding the visibility rules, the design bug is that the new name of a >> thing shall not hide any other names of it in any context. In the example >> above P1.End_Error should not have hidden P2.End_Error. (I don't know why >> this has not been fixed long time ago, because it would be a really minor >> language change, which would not break any existing code). > > You request that resolution would not be via names, but via entities. > Thus when there are several homonymes visible at the same time, the > compiler would have to check whether all these names actually specify > the same entity. Yes. > Don't know whether this would make overload > resolution more difficult. Maybe it would not, because the actions need only to be undertaken when a conflict is detected. Then the compiler would weed the list of conflicting names of same entities. That should not even slower the compilation (provided the feature would not be abused). -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de