comp.lang.ada
 help / color / mirror / Atom feed
From: "Randy Brukardt" <randy@rrsoftware.com>
Subject: Re: class wide iterable (and indexable)
Date: Thu, 3 Jan 2019 16:56:04 -0600
Date: 2019-01-03T16:56:04-06:00	[thread overview]
Message-ID: <q0m3u6$t9c$1@franka.jacob-sparre.dk> (raw)
In-Reply-To: 2a6929c5-72fa-4d84-953a-44ea4597ab38@googlegroups.com

"George Shapovalov" <gshapovalov@gmail.com> wrote in message 
news:2a6929c5-72fa-4d84-953a-44ea4597ab38@googlegroups.com...
...
>I did see in the Ada.Containers.Vectors code two versions defined, however 
>I was not
>clear on why, especially since both the Ada Gem 10x (I forgot now exact 
>number) and
>Ada Rationale for 2012 seem to only provide one, with a Cursor.

Vectors support both indexing by an integer and reference via a cursor. 
Usually, the List container is a better example for cursor operations 
because it doesn't have the confusion of (direct) indexing involved.

...
>On a related note, I was rather surprised that the related types in 
>Ada.Containers do not
>form such a hierarchy. Say both Ada.Containers.Vectors and 
>Indefinite_Vectors (and
>especially now with addition of Bounded_Vectors too) all could derive from 
>a common
>ancestor that could be used to implement common functionality and let end 
>user chose
>the desired data storage model..

Because that would substantially harm ease-of-use. You'd have to write 
multiple instantiations to create any container. It's annoying enough (to 
some, at least) to have to write one.

Besides, interfaces are (nearly) useless (and especially so for this sort of 
usage, where some part has to be generic). They add a lot of runtime 
overhead that doesn't actually get used in real programs. For example, we 
did do what you suggest for the queue containers. Irrelevant thought: that's 
probably why I have yet to hear of anyone actually using one of them. :-) 
Back to the point: there's virtually no circumstance where you'd use more 
than one type of queue with any specific data type, so the generality buys 
essentially nothing. (The only real use is in generic units, but those could 
have been handled with formal packages just as well.) So you're paying a 
substantial price in code size and time, but no real gain.

Perhaps if Ada allowed multiple controlling parameters of different tagged 
types, then there might be more use. But with the existing Ada rules, 
interfaces can only be useful if the profiles are fixed (non-generic) and 
are still reusable -- that doesn't happen that often.

                               Randy.





  parent reply	other threads:[~2019-01-03 22:56 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 [this message]
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
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