comp.lang.ada
 help / color / mirror / Atom feed
From: "Dan'l Miller" <optikos@verizon.net>
Subject: Re: Strings with discriminated records
Date: Mon, 28 May 2018 17:41:39 -0700 (PDT)
Date: 2018-05-28T17:41:39-07:00	[thread overview]
Message-ID: <e7cf79e8-7f66-4117-b058-e65753daa34e@googlegroups.com> (raw)
In-Reply-To: <7d38a160-35b8-4b39-bfe5-30b607645e93@googlegroups.com>

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:
> >    
> >    declare
> >       M : Nights.Message := Nights.Create ("Hello World");
> >    begin
> >       null;
> >    end;
> 
> One thing you could do here to reduce an assignment is change M's declaration to:
>        M : Nights.Message RENAMES Nights.Create ("Hello World");
> 
> This eliminates a whole set of adjust/finalize by eliminating the temporary anonymous object AND the assignment. (Ok, so it's really giving a name to 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 what are move semantics on the overloaded move constructor.

2) But perhaps this is more importantly for language design how much cleaner 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 at its scope of instantiation (although it is given a parameter name upon entry to the move-semantics overloaded member-functions); the rvalue-temporary's heavily-regulated ••address-of-sorts is captured•• 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.message := 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.
> 
> 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 “several releases”.  Regarding RENAMES, did AdaCore's customers also suffer such “bug-box” in GNAT Pro for “several releases”?

** assuming that C++'s brute-force moving of heaven & earth & every mountain 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 operators & member functions, i.e., the move constructor in this thread's case

> 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 GNAT at compile-time or wrong behavior at runtime?

  reply	other threads:[~2018-05-29  0:41 UTC|newest]

Thread overview: 51+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-26 21:43 Strings with discriminated records NiGHTS
2018-05-26 23:42 ` Shark8
2018-05-27  1:42   ` NiGHTS
2018-05-27  8:39     ` Dmitry A. Kazakov
2018-05-27 12:22       ` Mehdi Saada
2018-05-27 12:40         ` Dmitry A. Kazakov
2018-05-27 14:34       ` NiGHTS
2018-05-27 14:50         ` Dmitry A. Kazakov
2018-05-27 15:19           ` NiGHTS
2018-05-27 15:32             ` AdaMagica
2018-05-27 16:22               ` NiGHTS
2018-05-29 22:31           ` Randy Brukardt
2018-05-30  7:29             ` Dmitry A. Kazakov
2018-05-30 20:11               ` Randy Brukardt
2018-05-27 12:48     ` Mehdi Saada
2018-05-27 13:03       ` Dmitry A. Kazakov
2018-05-27 17:11 ` NiGHTS
2018-05-27 18:07   ` Simon Wright
2018-05-27 23:08     ` NiGHTS
2018-05-28  1:44       ` Jere
2018-05-28  3:05         ` NiGHTS
2018-05-28  3:23           ` NiGHTS
2018-05-27 18:25   ` Dmitry A. Kazakov
2018-05-27 22:44     ` NiGHTS
2018-05-28  7:29       ` Dmitry A. Kazakov
2018-05-28  7:42       ` Simon Wright
2018-05-28 18:38         ` Shark8
2018-05-28 21:15           ` Mehdi Saada
2018-05-28 21:48             ` Shark8
2018-05-28 22:27               ` Mehdi Saada
2018-05-28 23:59                 ` Shark8
2018-05-29  0:41                   ` Dan'l Miller [this message]
2018-05-30 17:11                     ` Shark8
2018-05-29  7:49                 ` Dmitry A. Kazakov
2018-05-29  9:31                   ` AdaMagica
2018-05-29 10:14                     ` Dmitry A. Kazakov
2018-05-29 13:40                   ` Dan'l Miller
2018-05-29 14:04                     ` Dmitry A. Kazakov
2018-05-29 22:41                       ` Randy Brukardt
2018-05-30  5:00                         ` J-P. Rosen
2018-05-30 20:09                           ` Randy Brukardt
2018-05-31  4:19                             ` J-P. Rosen
2018-05-31 22:18                               ` Randy Brukardt
2018-06-01 13:35                                 ` Dan'l Miller
2018-06-01 15:20                                   ` Dmitry A. Kazakov
2018-05-28 13:55 ` NiGHTS
2018-05-29 14:37 ` Mehdi Saada
2018-05-29 22:44   ` Randy Brukardt
2018-05-29 22:41 ` Mehdi Saada
2018-05-30 19:46   ` Randy Brukardt
2018-05-30 19:48     ` Randy Brukardt
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox