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=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM autolearn=ham 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!postnews.google.com!i4g2000yqg.googlegroups.com!not-for-mail From: AdaMagica Newsgroups: comp.lang.ada Subject: Re: Will "renames" increase program size? Date: Thu, 16 Jun 2011 03:18:14 -0700 (PDT) Organization: http://groups.google.com Message-ID: <4bdd2495-fb00-4aa7-89bd-910dfefa3704@i4g2000yqg.googlegroups.com> References: <46294109-f07d-49c0-8e81-65a369a05ced@z15g2000prn.googlegroups.com> <1ayjsy885qg2b$.13bmeo97hbau1$.dlg@40tude.net> <316ac8ed-1ded-43d0-98d1-36bb2c0221ad@f2g2000yqh.googlegroups.com> NNTP-Posting-Host: 91.7.117.145 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1308219494 15317 127.0.0.1 (16 Jun 2011 10:18:14 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Thu, 16 Jun 2011 10:18:14 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: i4g2000yqg.googlegroups.com; posting-host=91.7.117.145; posting-account=rmHyLAoAAADSQmMWJF0a_815Fdd96RDf User-Agent: G2/1.0 X-Google-Web-Client: true X-Google-Header-Order: HUALESNKRC X-HTTP-UserAgent: Mozilla/5.0 (Windows NT 6.0; rv:2.0.1) Gecko/20100101 Firefox/4.0.1,gzip(gfe) Xref: g2news1.google.com comp.lang.ada:19870 Date: 2011-06-16T03:18:14-07:00 List-Id: > No. First, sometimes it certainly copies, e.g. when the function's result > is renamed, the result (temporary object) is copied. The compiler might > optimize the temporary object away, or even mandated to do so for limited > results, but *semantically* it is a copy. OK, agreed, there are cases where rename does a copy. > procedure Shame is > =A0 =A0type T is array (Integer range <>) of Integer; > =A0 =A0A : T :=3D (0 =3D> 0, 1 =3D> 1); > =A0 =A0subtype S is T (1..2); > =A0 =A0B : S renames A; > begin > =A0 =A0Put_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.) > 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. Don't know whether this would make overload resolution more difficult.