comp.lang.ada
 help / color / mirror / Atom feed
From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: class wide iterable (and indexable)
Date: Sat, 5 Jan 2019 11:07:54 +0100
Date: 2019-01-05T11:07:54+01:00	[thread overview]
Message-ID: <q0pvlp$1vp1$1@gioia.aioe.org> (raw)
In-Reply-To: q0psvi$v1q$1@franka.jacob-sparre.dk

On 2019-01-05 10:21, Randy Brukardt wrote:
> "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> wrote in message
> news:q0n6av$1tqs$1@gioia.aioe.org...
> ...
>> In real programs dispatch is rare, thus there is no overhead.
> 
> This is probably true, but then interfaces are even more useless (they
> provide nothing that could possibly be of value other than dispatch!).

 From the SW design POV they provide a description of an interface, 
which is a lot of value as is.

>> I don't know which overhead Randy meant, though. Maybe, space overhead?
>> That is not nearly close to what generics produce in GNAT...
> 
> Dispatching is very expensive for interfaces, in that some form of search is
> needed. (Note: I have no idea how GNAT implements them exactly.) It might be
> possible to do some sort of link-time assignment of interface identifiers
> and link-time tag construction to avoid some of that cost (at the cost of a
> lot of space), but that would be such a complex and unusual project
> (conventional linkers don't support anything like that) that I've always
> considered it impraactical.

Bounded time dispatch must be a requirement of course. However I doubt 
that what we have now, a myriad of helper tagged types and objects 
created and destroyed all the time is more effective in any thinkable way.

> ...
>> No, interfaces cannot contain common code except for class-wide one. Is
>> that what Randy meant about overhead?
> 
> Not really. My main point is that you'll never have more than one concrete
> instance of a generic interface in any individual program (certainly not of
> an interface like that of a container),

I don't understand this. Usually I have dozens of instantiations of the 
same generics with different actual parameters.

> Note: I mean one concrete type, there might be many objects of that type.
> But it doesn't make sense to use bounded and indefinite containers at the
> same time for the same element type.

Of course it does. The best example is Ada strings, a container of 
characters. Practically every program in effect uses both bounded and 
unbounded strings, the later, maybe, in the form of access String (I 
tend to avoid Unbounded_String).

> Dmitry is of course an all-interface all the time sort of guy. All I see
> from that is a vast amount of typing to get nothing in particular in return.

You get type safety. Otherwise you can always go back K&R C! (:-))

> [But I'm not much of a fan of OOP, either; the big advantage of OOP is
> requiring few recompiles when adding features. That was a big deal in 1990,
> but it hardly matters today. (I can recompile the entirety of Janus/Ada -
> 250,000 lines - in 15 minutes or so. Why try to save compiles?) And for
> that, you get to type dozens and dozens of declarations to do anything.

That is because compilers are no longer large software, not even 
medium-size (:-)). My current project takes a half of week to recompile 
from scratch [*].

And recompilation is not the biggest problem. Deployment of the modules is.

> While the supposedly terrible case statement solution gives you case
> completeness checks, variant checks, and essentially has no more chance of
> failure (and costs a lot less, and keeps all of the similar code together
> rather that scattering it about to every different kind of object).

The main problem is that the "similar" code logically has nothing in 
common, except the shared interface. It must be written by different 
teams, at different locations and time. Independently tested, used, 
deployed, versioned, maintained. The case-statement solution crushes not 
only the architecture but all software process.

----------------------
* GNAT is awfully slow when compiling specifically generic 
instantiations, and I have lots of them. The more I have, the more I 
hate them.

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


  reply	other threads:[~2019-01-05 10:07 UTC|newest]

Thread overview: 76+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-02 15:48 class wide iterable (and indexable) George Shapovalov
2019-01-02 17:39 ` Simon Wright
2019-01-02 18:11   ` George Shapovalov
2019-01-03  8:52     ` Simon Wright
2019-01-03  9:30       ` George Shapovalov
2019-01-03 16:45         ` Jeffrey R. Carter
2019-01-04  4:32       ` Shark8
2019-01-05  9:03         ` Randy Brukardt
2019-01-03 22:56     ` Randy Brukardt
2019-01-04  0:00       ` George Shapovalov
2019-01-04  8:43         ` Dmitry A. Kazakov
2019-01-04 12:20           ` George Shapovalov
2019-01-05 23:29             ` Jere
2019-01-05 23:50               ` Jere
2019-01-06  9:34                 ` George Shapovalov
2019-01-06 10:19                   ` Dmitry A. Kazakov
2019-01-06 11:30                     ` George Shapovalov
2019-01-06 12:45                       ` Dmitry A. Kazakov
2019-01-06 13:18                         ` George Shapovalov
2019-01-06 14:13                           ` Dmitry A. Kazakov
2019-01-06 16:33                             ` George Shapovalov
2019-01-06 18:29                               ` George Shapovalov
2019-01-06 20:32                                 ` Dmitry A. Kazakov
2019-01-06 21:47                                   ` George Shapovalov
2019-01-07  9:37                                     ` Niklas Holsti
2019-01-07 16:24                                       ` George Shapovalov
2019-01-06 20:18                               ` Dmitry A. Kazakov
2019-01-06 21:58                                 ` George Shapovalov
2019-01-07  8:28                                   ` Dmitry A. Kazakov
2019-01-05  9:21           ` Randy Brukardt
2019-01-05 10:07             ` Dmitry A. Kazakov [this message]
2019-01-05 18:17               ` George Shapovalov
2019-01-05 20:07                 ` Simon Wright
2019-01-05 20:41                   ` George Shapovalov
2019-01-07 21:07               ` Randy Brukardt
2019-01-08  9:51                 ` Dmitry A. Kazakov
2019-01-08 19:25                   ` Björn Lundin
2019-01-08 23:26                   ` Randy Brukardt
2019-01-09 17:06                     ` Dmitry A. Kazakov
2019-01-09 23:38                       ` Randy Brukardt
2019-01-10  8:53                         ` Dmitry A. Kazakov
2019-01-10 22:14                           ` Randy Brukardt
2019-01-11  9:09                             ` Dmitry A. Kazakov
2019-01-14 22:59                               ` Randy Brukardt
2019-01-15  9:34                                 ` Dmitry A. Kazakov
2019-01-18 15:48                                   ` Olivier Henley
2019-01-18 16:08                                     ` Dmitry A. Kazakov
2019-01-18 16:29                                       ` Olivier Henley
2019-01-18 16:54                                         ` Dmitry A. Kazakov
2019-01-18 17:31                                           ` Olivier Henley
2019-01-18 18:51                                             ` Shark8
2019-01-18 20:09                                             ` Dmitry A. Kazakov
2019-01-21 23:15                                     ` Randy Brukardt
2019-01-22  8:56                                       ` Dmitry A. Kazakov
2019-01-22 22:00                                         ` Randy Brukardt
2019-01-23  8:14                                           ` Dmitry A. Kazakov
2019-01-22 17:04                                       ` Jeffrey R. Carter
2019-01-22 22:02                                         ` Randy Brukardt
2019-01-23 18:00                                           ` Jeffrey R. Carter
2019-01-23 20:14                                           ` Shark8
2019-01-23 22:47                                             ` Randy Brukardt
2019-01-24 17:11                                               ` Dmitry A. Kazakov
2019-01-28 15:54                                               ` Shark8
2019-01-28 17:23                                                 ` Dmitry A. Kazakov
2019-01-08 18:32                 ` G. B.
2019-01-05 17:05             ` Jeffrey R. Carter
2019-01-05 20:18               ` Dmitry A. Kazakov
2019-01-05 21:09               ` Shark8
2019-01-06 10:11                 ` Jeffrey R. Carter
2019-01-05 20:46             ` Shark8
2019-01-06  9:43               ` Dmitry A. Kazakov
2019-01-26 22:11 ` George Shapovalov
2019-01-26 22:14   ` George Shapovalov
  -- strict thread matches above, loose matches on Subject: below --
2019-01-29  7:45 Randy Brukardt
2019-01-29 19:34 ` Niklas Holsti
2019-01-29 20:26   ` Dmitry A. Kazakov
replies disabled

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