comp.lang.ada
 help / color / mirror / Atom feed
From: "G.B." <bauhaus@notmyhomepage.invalid>
Subject: Re: ADA.STRINGS.INDEX_ERROR : a-strunb.adb:782
Date: Mon, 22 Jan 2018 00:27:33 +0100
Date: 2018-01-22T00:27:33+01:00	[thread overview]
Message-ID: <p437l6$2lt$1@dont-email.me> (raw)
In-Reply-To: <2c7bd6af-5eb8-415b-8808-e8d85c0c4d99@googlegroups.com>

On 18.01.18 15:17, Mehdi Saada wrote:
> Since universal_integer is meant to be compatible with everything, and since Ada83 is long gone,
> could "function Length return Integer renames Object_Array'Length" be accepted now ? I don't think it could break any existing code to accept something that wasn't.
> 

There is more to 'Image, which is a type attribute like 'Size.
Handling types is the realm of compilers.

Consider 'Value, which is paired with 'Image. Suppose there is
an enumeration subtype like that of

    type T is ('$', '¥', '£');

We now have

    X = T'Value (T'Image (X))

and, usually,

    S = T'Image (T'Value (S))


However, given the history of String design in programming
languages, things have become tricky.

Not because of a lack of symmetry between 'Image and 'Value
as written above.
Rather, I think, because of that tendency in language design
which bows before elementary school training. Hence,
Ada has removed symmetry: for example, in place of making
"+" a required part of numeric literals such as are input
to 'Image, it can be omitted. So, these values are now all
equal in Ada:

  Positive'Value ("42")
  Positive'Value (" 42")
  Positive'Value ("+42")
  Positive'Value ("   42  ")
  Positive'Value ("+42        ")

Very flexible and convenient, at first sight, I think. And done
for good reasons, at the time, perhaps: because, for output,
everyone would use an instance of a package from Text_IO,
and not 'Image. Right? No problem could have been anticipated.

This design decision has led to an endless discussion about
leading spaces in the result of 'Image for non-negatives.
At the root, elementary school habits in engineering make
programmers proudly dismiss the idea of writing numbers
symmetrically, with signs for both negatives and positives,
and maybe some technical prefix like " " attached to (non-FPT) 0.

OTOH, if programmers are smart enough to handle the compiler's
job of defining 'Image and 'Value, they are able to perform
well as substitutes: by providing the compiler with all correct
implementations for parsing and printing all user-defined literals
of any user-defined type.

      parent reply	other threads:[~2018-01-21 23:27 UTC|newest]

Thread overview: 50+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-15  1:18 ADA.STRINGS.INDEX_ERROR : a-strunb.adb:782 Mehdi Saada
2018-01-15  3:23 ` Niklas Holsti
2018-01-15  8:29 ` Dmitry A. Kazakov
2018-01-15 10:49   ` Simon Wright
2018-01-15 11:51     ` Mehdi Saada
2018-01-15 12:00       ` Mehdi Saada
2018-01-15 13:32         ` Dmitry A. Kazakov
2018-01-15 18:55         ` Shark8
2018-01-15 13:51       ` Simon Wright
2018-01-15 15:18         ` Mehdi Saada
2018-01-15 15:29           ` Mehdi Saada
2018-01-15 15:50             ` Mehdi Saada
2018-01-15 17:53               ` Simon Wright
2018-01-15 17:22   ` Anh Vo
2018-01-15 17:48     ` Dmitry A. Kazakov
2018-01-15 19:56       ` Anh Vo
2018-01-16 16:06     ` Brian Drummond
2018-01-16 17:21       ` Anh Vo
2018-01-15 10:37 ` Simon Wright
2018-01-15 16:06 ` Mehdi Saada
2018-01-17 19:23   ` Niklas Holsti
2018-01-16 16:24 ` Mehdi Saada
2018-01-16 18:20   ` Jacob Sparre Andersen
2018-01-16 20:00     ` Mehdi Saada
2018-01-17 15:45 ` Mehdi Saada
2018-01-17 16:30   ` Dmitry A. Kazakov
2018-01-17 22:50     ` Mehdi Saada
2018-01-18  8:34       ` Dmitry A. Kazakov
2018-01-18 11:14         ` Simon Wright
2018-01-18 11:55           ` Dmitry A. Kazakov
2018-01-18 12:21             ` Mehdi Saada
2018-01-18 13:08               ` J-P. Rosen
2018-01-18 15:23                 ` Dmitry A. Kazakov
2018-01-19  1:10                   ` Randy Brukardt
2018-01-19  8:52                     ` Dmitry A. Kazakov
2018-01-20  0:42                       ` Randy Brukardt
2018-01-20  9:47                         ` Dmitry A. Kazakov
2018-01-23  0:44                           ` Randy Brukardt
2018-01-18 14:05         ` AdaMagica
2018-01-18 14:17           ` Mehdi Saada
2018-01-18 14:56             ` J-P. Rosen
2018-01-18 15:38               ` Mehdi Saada
2018-01-19  1:13                 ` Randy Brukardt
2018-01-18 16:48             ` AdaMagica
2018-01-18 16:59               ` Dmitry A. Kazakov
2018-01-18 19:36                 ` Mehdi Saada
2018-01-19  1:21                   ` Randy Brukardt
2018-01-19 16:15                 ` AdaMagica
2018-01-19 16:58                   ` Dmitry A. Kazakov
2018-01-21 23:27             ` G.B. [this message]
replies disabled

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