comp.lang.ada
 help / color / mirror / Atom feed
From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: grassroots thoughts on access types
Date: Fri, 9 Feb 2018 18:19:27 +0100
Date: 2018-02-09T18:19:27+01:00	[thread overview]
Message-ID: <p5kl6u$12m5$1@gioia.aioe.org> (raw)
In-Reply-To: p5kk5i$5fj$1@dont-email.me

On 2018-02-09 18:01, Jeffrey R. Carter wrote:
> Others have responded to your questions. I'd like to mention my thoughts 
> on using access-to-object types (which I'll call "access types") in 
> general. (By "use", I'm referring to designing code with access types, 
> not to using them when required to in order to reuse existing code. 
> Gnoga, for example, requires you to supply some access values to use it.)
> 
> It's very rare to actually need to use access types in Ada. Other than 
> while learning the language, it's quite likely that you'll never 
> encounter a situation in which you'll need them. So while it's important 
> to learn how they work, you shouldn't be designing in terms of them.
> 
> My personal rules for designing with access types:
> 
> 1. Don't use access types
> 2. If you think you need access types, see rule 1.
> 3. If you still think you need access types, don't use visible or 
> anonymous access types
> 4. If you think you need visible or anonymous access types, see rule 3.
> 5. If you still think you need visible or anonymous access types, then 
> you shouldn't design software.

I mostly agree with that, yet there are some notable exceptions from 
these rules.

a. Dispatching operation. It cannot have a named access type. The 
conflicting design rule here is that *all* operations must be 
dispatching and any type must have a class.

b. Anonymous access type accepts arguments without explicit type 
conversion. Type conversions are always bad, ones exposing run-time 
hazard are more than bad.

c. Mix-in discriminant, anonymous access type is the only way in many 
cases. Mix-in itself is a horrid design pattern, but there is no 
multiple inheritance here to replace mix-in and no proper classes of 
protected and task types either.

In general, anonymous access type is the only way to enforce referential 
semantics. It would be great if Ada had it decoupled that from pointers. 
Unfortunately it did not.

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de

  reply	other threads:[~2018-02-09 17:19 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-09  0:46 grassroots thoughts on access types Mehdi Saada
2018-02-09  1:23 ` Randy Brukardt
2018-02-09  9:13   ` Simon Wright
2018-02-09 11:06     ` Dmitry A. Kazakov
2018-02-09 12:09 ` Mehdi Saada
2018-02-09 12:11   ` Mehdi Saada
2018-02-09 14:23     ` Simon Wright
2018-02-09 16:11       ` Mehdi Saada
2018-02-09 17:01 ` Jeffrey R. Carter
2018-02-09 17:19   ` Dmitry A. Kazakov [this message]
2018-02-09 19:12     ` Jeffrey R. Carter
2018-02-09 20:17       ` Robert A Duff
2018-02-09 21:44         ` Jeffrey R. Carter
2018-02-09 22:06           ` Dmitry A. Kazakov
2018-02-10  0:43             ` Mehdi Saada
2018-02-10  1:51               ` Mehdi Saada
2018-02-10 10:07                 ` Jeffrey R. Carter
2018-02-10 11:57                 ` Mehdi Saada
2018-02-10 14:02                   ` Simon Wright
2018-02-10 15:32                   ` Jeffrey R. Carter
2018-02-10 16:46                     ` Mehdi Saada
2018-02-10  8:28               ` Dmitry A. Kazakov
2018-02-10 11:55                 ` Mehdi Saada
2018-02-10 14:35                   ` Dmitry A. Kazakov
2018-02-10 16:51                     ` Simon Wright
2018-02-10 17:19                       ` Dmitry A. Kazakov
2018-02-10 10:03             ` Jeffrey R. Carter
2018-02-10 10:36               ` Dmitry A. Kazakov
2018-02-10 11:12                 ` Jeffrey R. Carter
2018-02-10 14:44                   ` Dmitry A. Kazakov
2018-02-10 21:16           ` Robert A Duff
2018-02-11 10:47             ` Jeffrey R. Carter
2018-02-11 21:51               ` Robert A Duff
2018-02-09 20:58       ` Shark8
2018-02-09 20:32 ` G. B.
2018-02-09 20:53   ` Mehdi Saada
replies disabled

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