comp.lang.ada
 help / color / mirror / Atom feed
From: Shark8 <onewingedshark@gmail.com>
Subject: Re: Ada design bug or GNAT bug?
Date: Tue, 23 Jun 2015 12:55:14 -0700 (PDT)
Date: 2015-06-23T12:55:14-07:00	[thread overview]
Message-ID: <28155a3e-404a-4ee8-9f44-dc50601cc231@googlegroups.com> (raw)
In-Reply-To: <49c10d77-f026-48ec-9339-e47ea94ac66a@googlegroups.com>

On Tuesday, June 23, 2015 at 5:51:13 AM UTC-6, vincent....@gmail.com wrote:
> Le lundi 22 juin 2015 20:27:17 UTC+2, Shark8 a écrit :
> 
> > * Ada95's modular types combine the orthogonal idea of a cyclic numeric type and an unsigned type -- conceptually it could have been better to separate the two.
> 
> Could you tell us a bit more on that ? Why would it be better to separate Unsigned Integer and modular types ? I had the impression that a compiler could use a unsigned integer representation for such integer declaration :
> 
> type Unsigned is range 0 .. 2**32 -1;

Well, the simplest example would be clock time:
    Type CIVIL_HOUR is range 1..12 --...with some way to indicate cyclic.

Obviously here we have a numeric type that needs to cycle, but which has a 'First of non-zero and lies completely in POSITIVE.

> Since converting to a Standard.Integer requires anyway to use an explicit
> conversion in the Ada language because of strong typing, not mentionning run-time tests on range, I thought it would be easy for the compiler to insert conversion between signed and unsigned.

"Easy" might not be the right word, but 'doable' I think fits.

> But it seems that Ada implementations prefer to use 
> 
> type Unsigned is mod 2**32;
> 
> But what is the problem with this ? Detection of overflow ?

No, overflow is not a problem here, the MOD is indicating that the values of the type are cyclic... the problem is that this implicitly makes 'First 0 and there's no way to indicate that the cycle doesn't start at 0.

> > * The lack of a "abstract type" that could be used to unify (e.g.) [[Wide_[Wide_]]String into a single "generic"/abstract type; ditto on Character.
> 
> Same question : what would be your proposal ?

I'm not great [or even good] at language-design, but I would think something along the lines of how we contract generics via the generic's parameters only instead of operating on subprograms/packages it would be types themselves.

Perhaps something like:

   -- Analog of:
   -- Generic
   --   Type Actual is (<>);
   -- ...
   Abstract Type Abstract_Character is (<>);
   
   -- Analog of:
   -- Generic
   --   Type Element is (<>);
   --   Type Index is (<>);
   --   Type Actual is Array(Index range <>) of Element;
   -- ...
   Abstract Type Abstract_String( Positive Range <> ) of Abstract_Character;

  reply	other threads:[~2015-06-23 19:55 UTC|newest]

Thread overview: 46+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-20 18:55 Ada design bug or GNAT bug? Dmitry A. Kazakov
2015-06-21  2:42 ` Randy Brukardt
2015-06-21  6:47   ` Dmitry A. Kazakov
2015-06-22 17:39     ` Randy Brukardt
2015-06-22 18:16       ` Dmitry A. Kazakov
2015-06-23 11:00         ` G.B.
2015-06-23 14:27           ` Dmitry A. Kazakov
2015-06-23 11:45         ` G.B.
2015-06-23 14:30           ` Dmitry A. Kazakov
2015-07-02 22:22         ` Randy Brukardt
2015-07-03  8:02           ` Dmitry A. Kazakov
2015-07-03 17:33             ` Randy Brukardt
2015-07-03 21:34               ` Dmitry A. Kazakov
2015-07-04  3:11                 ` Randy Brukardt
2015-07-04 12:14                   ` Dmitry A. Kazakov
2015-07-05  0:53                     ` Randy Brukardt
2015-06-22 18:27       ` Shark8
2015-06-23 11:51         ` vincent.diemunsch
2015-06-23 19:55           ` Shark8 [this message]
2015-06-23 13:06         ` vincent.diemunsch
2015-06-23 14:30           ` David Botton
2015-06-23 15:57             ` Niklas Holsti
2015-06-23 16:01               ` G.B.
2015-06-23 18:05               ` David Botton
2015-06-23 19:38               ` David Botton
2015-06-23 14:38           ` Dmitry A. Kazakov
2015-06-23 16:57             ` Vincent
2015-06-23 17:15               ` Dmitry A. Kazakov
2015-06-23 19:14                 ` vincent.diemunsch
2015-06-23 19:33                   ` Dmitry A. Kazakov
2015-06-23 17:42           ` Jeffrey R. Carter
2015-07-02 22:06           ` Randy Brukardt
2015-07-04  1:52             ` Shark8
2015-07-04  3:24               ` Randy Brukardt
2015-07-04 11:02                 ` Build-in-place semantics? (Was: Ada design bug or GNAT bug?) Jacob Sparre Andersen
2015-07-04 12:15                   ` Dmitry A. Kazakov
2015-07-05  0:45                     ` Randy Brukardt
2015-07-05  7:10                       ` Dmitry A. Kazakov
2015-07-05  0:40                   ` Randy Brukardt
2015-07-04 14:05                 ` Ada design bug or GNAT bug? Bob Duff
2015-07-04  7:46               ` Simon Wright
2015-07-04 12:00                 ` Björn Lundin
2015-07-05  0:48                   ` Randy Brukardt
2015-07-06 12:37             ` Vincent
2015-07-06 20:05               ` Randy Brukardt
2015-07-07  8:06               ` 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