From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM autolearn=unavailable autolearn_force=no version=3.4.4 X-Received: by 10.66.118.135 with SMTP id km7mr50838594pab.4.1435089314588; Tue, 23 Jun 2015 12:55:14 -0700 (PDT) X-Received: by 10.182.20.108 with SMTP id m12mr282160obe.28.1435089314547; Tue, 23 Jun 2015 12:55:14 -0700 (PDT) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!mx02.eternal-september.org!feeder.eternal-september.org!news.glorb.com!h15no7592831igd.0!news-out.google.com!a16ni2733ign.0!nntp.google.com!j8no572030igd.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Tue, 23 Jun 2015 12:55:14 -0700 (PDT) In-Reply-To: <49c10d77-f026-48ec-9339-e47ea94ac66a@googlegroups.com> Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=67.0.25.121; posting-account=lJ3JNwoAAAAQfH3VV9vttJLkThaxtTfC NNTP-Posting-Host: 67.0.25.121 References: <4lrj5zz2u2z.u8x9cf7xzic6.dlg@40tude.net> <49c10d77-f026-48ec-9339-e47ea94ac66a@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <28155a3e-404a-4ee8-9f44-dc50601cc231@googlegroups.com> Subject: Re: Ada design bug or GNAT bug? From: Shark8 Injection-Date: Tue, 23 Jun 2015 19:55:14 +0000 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Xref: news.eternal-september.org comp.lang.ada:26444 Date: 2015-06-23T12:55:14-07:00 List-Id: 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 =E9crit=A0: >=20 > > * Ada95's modular types combine the orthogonal idea of a cyclic numeric= type and an unsigned type -- conceptually it could have been better to sep= arate the two. >=20 > 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 : >=20 > 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 ins= ert 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=20 >=20 > type Unsigned is mod 2**32; >=20 > But what is the problem with this ? Detection of overflow ? No, overflow is not a problem here, the MOD is indicating that the values o= f 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.) [[Wi= de_[Wide_]]String into a single "generic"/abstract type; ditto on Character= . >=20 > Same question : what would be your proposal ? I'm not great [or even good] at language-design, but I would think somethin= g along the lines of how we contract generics via the generic's parameters = only instead of operating on subprograms/packages it would be types themsel= ves. Perhaps something like: -- Analog of: -- Generic -- Type Actual is (<>); -- ... Abstract Type Abstract_Character is (<>); =20 -- 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= ;