comp.lang.ada
 help / color / mirror / Atom feed
From: Matt Borchers <mattborchers@gmail.com>
Subject: Re: array from static predicate on enumerated type
Date: Mon, 15 Mar 2021 07:11:23 -0700 (PDT)	[thread overview]
Message-ID: <26c44e00-a899-455a-a929-1e23c7935fe3n@googlegroups.com> (raw)
In-Reply-To: <s2hrn2$3ee$1@gioia.aioe.org>

So, what I'm taking away from this discussion is that instantiating a Map is pretty much the best option when using a sub-type with a Static_Predicate to map a parent value to a sub-type.  The simple example I gave here is a one-dimensional array and what I actually have implemented is a multi-dimensional array.  I will have to do tests on the performance of a map of a map of a map of a...

The IN and INDEX operations (in this case sub-type'Pos) are very closely related and so in my mind and it would seem that if IN works, then indexing should work as well given a mapping function.  A map function in this case, to me at least, is a black box that takes an Integer input and outputs an Integer.  Doesn't a memory array (contiguous memory, not Ada array, possibly using a binary search) do this very quickly and a function or some other data structure a bit slower?  It seems the compiler could create this for the programmer if necessary.  I was only trying to suggest that when a new syntax feature is added, that it is very surprising that it would break seemingly simple things like attributes and arrays.  If using Static_Predicate induces a run-time cost in some instances then so be it -- the programmer can decide if the cost is unreasonable.  That is the nature of all programming -- finding the ideal solution to a problem given the constraints of the system in which it operates be it speed, memory footprint, etc.  I would not argue that speed is always of utmost importance.

It seems like the Ada community is always chasing higher adoption and better recognition of the Ada language.  If the community truly wants this, then Ada needs to be accessible as a general purpose language with very few surprises.  I evangelize for Ada when I can but I am of the opinion that language rules like these only frustrate people when create seemingly inconsistent usability.  There may be a good technical reason to break the behavior, but in this example and in my opinion, the technical excuse is not good enough when there is a very simple solution that the programmer should not have to implement.  My 2 cents.

Matt

  reply	other threads:[~2021-03-15 14:11 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-12 20:49 array from static predicate on enumerated type Matt Borchers
2021-03-12 21:22 ` Egil H H
2021-03-12 22:16 ` Jeffrey R. Carter
2021-03-12 22:41 ` Dmitry A. Kazakov
2021-03-13  2:06   ` Matt Borchers
2021-03-13  4:55     ` Randy Brukardt
2021-03-15 14:16       ` Matt Borchers
2021-03-15 17:53         ` Shark8
2021-03-16  6:58         ` Randy Brukardt
2021-03-13  8:04     ` Dmitry A. Kazakov
2021-03-15 14:11       ` Matt Borchers [this message]
2021-03-15 17:48         ` Shark8
2021-03-15 20:25           ` Dmitry A. Kazakov
2021-03-16 13:27             ` Shark8
2021-03-16 14:25               ` Dmitry A. Kazakov
2021-03-17  4:05                 ` Matt Borchers
2021-03-17  7:08                   ` Dmitry A. Kazakov
2021-03-17 18:44                     ` Matt Borchers
2021-03-17 19:41                       ` Dmitry A. Kazakov
2021-03-18  1:30                         ` Matt Borchers
2021-03-18  8:20                           ` Dmitry A. Kazakov
2021-03-19  0:10                             ` Matt Borchers
2021-03-19  8:00                               ` Dmitry A. Kazakov
2021-03-18 10:15                           ` Niklas Holsti
2021-03-18 10:47                             ` AdaMagica
2021-03-18 11:26                               ` Dmitry A. Kazakov
2021-03-19  0:34                             ` Matt Borchers
2021-03-19  0:49                               ` Jeffrey R. Carter
2021-03-23  1:07                                 ` Matt Borchers
2021-03-23  3:43                                   ` Randy Brukardt
2021-03-22 19:09                               ` Niklas Holsti
2021-03-17 15:08                   ` Shark8
2021-03-17 19:08                     ` Matt Borchers
2021-03-17 20:41                       ` Shark8
2021-03-18  1:04                         ` Matt Borchers
2021-03-18 14:25                           ` Shark8
2021-03-18 23:36                             ` Matt Borchers
2022-03-16  0:38             ` Thomas
replies disabled

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