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 autolearn=unavailable autolearn_force=no version=3.4.4 X-Received: by 2002:a24:d643:: with SMTP id o64-v6mr7054249itg.48.1527554500162; Mon, 28 May 2018 17:41:40 -0700 (PDT) X-Received: by 2002:a9d:4795:: with SMTP id b21-v6mr150093otf.10.1527554499951; Mon, 28 May 2018 17:41:39 -0700 (PDT) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!feeder.eternal-september.org!news.uzoreto.com!weretis.net!feeder6.news.weretis.net!feeder.usenetexpress.com!feeder-in1.iad1.usenetexpress.com!border1.nntp.dca1.giganews.com!nntp.giganews.com!v8-v6no5876372itc.0!news-out.google.com!b185-v6ni5022itb.0!nntp.google.com!u74-v6no5849234itb.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Mon, 28 May 2018 17:41:39 -0700 (PDT) In-Reply-To: <7d38a160-35b8-4b39-bfe5-30b607645e93@googlegroups.com> Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=47.185.233.194; posting-account=zwxLlwoAAAChLBU7oraRzNDnqQYkYbpo NNTP-Posting-Host: 47.185.233.194 References: <55ce14eb-6b83-4ea0-a550-f9e1410d0b06@googlegroups.com> <51dfb377-1b3e-45ca-a211-158101efe557@googlegroups.com> <090d6eb2-9f52-4471-a22e-ce1bdf457188@googlegroups.com> <90f0f8da-dadd-4341-bc0f-dbda94b0516c@googlegroups.com> <137bcc76-2489-4557-979b-5efeecbd9289@googlegroups.com> <7d38a160-35b8-4b39-bfe5-30b607645e93@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: Subject: Re: Strings with discriminated records From: "Dan'l Miller" Injection-Date: Tue, 29 May 2018 00:41:40 +0000 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Xref: reader02.eternal-september.org comp.lang.ada:52756 Date: 2018-05-28T17:41:39-07:00 List-Id: On Monday, May 28, 2018 at 1:38:27 PM UTC-5, Shark8 wrote: > On Monday, May 28, 2018 at 1:42:24 AM UTC-6, Simon Wright wrote: > > =20 > > declare > > M : Nights.Message :=3D Nights.Create ("Hello World"); > > begin > > null; > > end; >=20 > One thing you could do here to reduce an assignment is change M's declara= tion to: > M : Nights.Message RENAMES Nights.Create ("Hello World"); >=20 > This eliminates a whole set of adjust/finalize by eliminating the tempora= ry anonymous object AND the assignment. (Ok, so it's really giving a name t= o the anonymous object so you can use it directly.) Whoa! With C++ move semantics in mind, this is by far the most remarkable = multifaceted lesson to teach in this whole thread. 1) This is a lesson not only of how to use Ada to accomplish more simply wh= at are move semantics on the overloaded move constructor. 2) But perhaps this is more importantly for language design how much cleane= r RENAMES reads than all the && move-semantics crypto syntax through the &&= -overloaded-member-function backdoor that C++ has to accomplish (much) the = same thing. (In C++, the rvalue-temporary isn't given an identifier name a= t its scope of instantiation (although it is given a parameter name upon en= try to the move-semantics overloaded member-functions); the rvalue-temporar= y's heavily-regulated =E2=80=A2=E2=80=A2address-of-sorts is captured=E2=80= =A2=E2=80=A2 for use within move-semantics overloaded member-functions.) 3) Plus, remember to keep RENAMES in mind when writing those Ada-versus-C++= bake-off competitions between languages. Both for readability compared to= the notoriously subtly-cantankerous* move semantics, as well as having Ada= match C++'s efficiency regarding what C++ calls move semantics. * See Scott Meyers' horror book _Effective Modern C++: 42 Specific Ways to= Improve Your Use of C++11 and C++14_, especially horror stories #23 though= #30, er, I mean the advice in #23 through #30, which is Chapter 5. http://shop.oreilly.com/product/0636920033707.do On Monday, May 28, 2018 at 6:59:53 PM UTC-5, Shark8 wrote: > On Monday, May 28, 2018 at 4:27:26 PM UTC-6, Mehdi Saada wrote: > > I see, and I would expect a constant declaration M: constant nights.mes= sage :=3D nights.create("hello world); > > to have exactly the same implementation. I am right ? > > After all you do or not do exactly the same, as far as I understood. >=20 > According to the LRM, this is true. > This is [possibly] untrue in GNAT -- the past several releases Wow! A major** semantics bug in FSF GNAT for =E2=80=9Cseveral releases=E2= =80=9D. Regarding RENAMES, did AdaCore's customers also suffer such =E2=80= =9Cbug-box=E2=80=9D in GNAT Pro for =E2=80=9Cseveral releases=E2=80=9D? ** assuming that C++'s brute-force moving of heaven & earth & every mountai= n in sight to make their analogue*** of RENAMES work in C++11, C++14, and C= ++17 is a measure of how important move semantics are. *** move semantics via && crypto syntax on (the verbosity of) overloaded op= erators & member functions, i.e., the move constructor in this thread's cas= e > have bug-boxed on several rename features. (Really frustrating, as I tend= to favor RENAME over CONSTANT when possible.) What are the precise bugs that you have observed with RENAMES? Crash of GN= AT at compile-time or wrong behavior at runtime?