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: 103376,a41c4a2c795dbe34 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,UTF8 Path: g2news2.google.com!news3.google.com!feeder.news-service.com!94.75.214.39.MISMATCH!aioe.org!.POSTED!not-for-mail From: =?utf-8?Q?Yannick_Duch=C3=AAne_=28Hibou57?= =?utf-8?Q?=29?= Newsgroups: comp.lang.ada Subject: Re: Will "renames" increase program size? Date: Sat, 18 Jun 2011 10:58:49 +0200 Organization: Ada @ Home Message-ID: References: <46294109-f07d-49c0-8e81-65a369a05ced@z15g2000prn.googlegroups.com> <1ayjsy885qg2b$.13bmeo97hbau1$.dlg@40tude.net> <316ac8ed-1ded-43d0-98d1-36bb2c0221ad@f2g2000yqh.googlegroups.com> <2e8222df-9b82-497f-9dc4-5cb0d5653550@f31g2000pri.googlegroups.com> <1t5j5p8gurul3$.k4cq2qnsbbjb.dlg@40tude.net> <12lr1j2mmzidu.18gjo4p3e73kk$.dlg@40tude.net> NNTP-Posting-Host: jhB4zEd8h0hVueABBEv+1w.user.speranza.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed; delsp=yes Content-Transfer-Encoding: Quoted-Printable X-Complaints-To: abuse@aioe.org User-Agent: Opera Mail/11.11 (Linux) X-Notice: Filtered by postfilter v. 0.8.2 Xref: g2news2.google.com comp.lang.ada:20922 Date: 2011-06-18T10:58:49+02:00 List-Id: Le Sat, 18 Jun 2011 09:54:29 +0200, Dmitry A. Kazakov = a =C3=A9crit: > Does this copy? It seems that according to you, you cannot tell withou= t > looking into the body of Foo: > > function Foo return T is -- This copies > Result : T; > begin > return T; > end Foo; > > function Foo return T is -- This does not copy > begin > return Result : T; > end Foo; May be I did not really understood what you meant, but a simple test = program shows this makes no difference: -- Begin Test.adb = ------------------------------------------------------------ with Ada.Text_IO; procedure Test is Foo_1_Seed : Integer :=3D 0; function Foo_1 return Integer is Result : constant Integer :=3D Foo_1_Seed; begin Foo_1_Seed :=3D Foo_1_Seed + 1; return Result; end; Foo_2_Seed : Integer :=3D 0; function Foo_2 return Integer is begin return Result : constant Integer :=3D Foo_2_Seed do Foo_2_Seed :=3D Foo_2_Seed + 1; end return; end; Foo_1_1 : Integer renames Foo_1; Foo_1_2 : Integer renames Foo_1; Foo_1_3 : Integer renames Foo_1; Foo_2_1 : Integer renames Foo_2; Foo_2_2 : Integer renames Foo_2; Foo_2_3 : Integer renames Foo_2; procedure Put (Label : in String; Value : in Integer) is package Text_IO renames Ada.Text_IO; package Integer_IO is new Ada.Text_IO.Integer_IO (Integer); begin Text_IO.Put (Label); Text_IO.Put (" is "); Integer_IO.Put (Value); Text_IO.New_Line; end; begin Put (Label =3D> "Foo_1_1", Value =3D> Foo_1_1); Put (Label =3D> "Foo_1_2", Value =3D> Foo_1_2); Put (Label =3D> "Foo_1_3", Value =3D> Foo_1_3); Put (Label =3D> "Foo_2_1", Value =3D> Foo_2_1); Put (Label =3D> "Foo_2_2", Value =3D> Foo_2_2); Put (Label =3D> "Foo_2_3", Value =3D> Foo_2_3); end Test; -- End of Test.adb = ----------------------------------------------------------- And the output: -- Begin Output ------ Foo_1_1 is 0 Foo_1_2 is 1 Foo_1_3 is 2 Foo_2_1 is 0 Foo_2_2 is 1 Foo_2_3 is 2 -- End of Output ----- -- = =E2=80=9CSyntactic sugar causes cancer of the semi-colons.=E2=80=9D [Ep= igrams on = Programming =E2=80=94 Alan J. =E2=80=94 P. Yale University] =E2=80=9CStructured Programming supports the law of the excluded muddle.= =E2=80=9D [Idem] Java: Write once, Never revisit