comp.lang.ada
 help / color / mirror / Atom feed
From: "Jeffrey R. Carter" <jrcarter@acm.org>
Subject: Re: Unsigned Integer Restraint Errors
Date: Tue, 13 Mar 2007 16:16:07 GMT
Date: 2007-03-13T16:16:07+00:00	[thread overview]
Message-ID: <b7AJh.15305$PF.890@attbi_s21> (raw)
In-Reply-To: <et57ho$bjm$1@jacob-sparre.dk>

Randy Brukardt wrote:
> 
> And the supposedly unchecked signed type is not unchecked in any useful
> way...the only difference might be to remove code generated to make checks,
> and that isn't even guaranteed.
> 
>               Randy.
> 
> (*) ISO published the Amendment on March 9th. So Ada 95 is now
> obsolete...and "Ada" includes the Amendment.

Yes, I should have said "Ada 95", since I haven't looked at everything 
in the new standard yet, specifically suppressing checks. Now that I 
have looked at that section, I see that Ada (used properly this time) no 
longer has a way to specify a desire for unchecked, signed integer types 
(except Annex J). Suppressing overflow checks in general is not the same 
thing.

It may take me time to get used to the name change; at least I'm not 
writing 2006 for the date anymore ...

Perhaps if we were starting from scratch we could do something like

type T is range Min .. Max;

If Min is negative, T'Base is a signed type; otherwise, T'Base is an 
unsigned type.

There would be a pragma, something like

pragma Unchecked_Integer (T);

which would give T'Base the semantics of an Ada modular type if T'Base 
is unsigned. It would have a similar effect if T'Base is signed, which 
could be defined in Ada terms as unchecked converting the value to a 
modular type of the same size, performing operations with that modular 
type, and unchecked converting back to T'Base.

I just made this up, so I'm sure there are things I haven't considered. 
I'm assuming 2s-complement signed integers, for one thing.

-- 
Jeff Carter
"If you don't get the President of the United States on that
phone, ... you're going to have to answer to the Coca-Cola
Company."
Dr. Strangelove
32



  parent reply	other threads:[~2007-03-13 16:16 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-03-12 15:07 Unsigned Integer Restraint Errors frikk
2007-03-12 16:27 ` Georg Bauhaus
2007-03-12 17:17 ` Adam Beneschan
2007-03-12 17:23 ` Adam Beneschan
2007-03-12 18:11   ` frikk
2007-03-12 20:00     ` frikk
2007-03-12 20:07       ` Adam Beneschan
2007-03-12 18:00 ` Dmitry A. Kazakov
2007-03-12 19:00   ` Martin Krischik
2007-03-12 21:13     ` Dmitry A. Kazakov
2007-03-12 19:13   ` frikk
2007-03-12 19:22     ` Randy Brukardt
2007-03-13  3:13       ` Jeffrey R. Carter
2007-03-13  3:00         ` Randy Brukardt
2007-03-13 12:09           ` frikk
2007-03-13 14:58             ` frikk
2007-03-13 15:31               ` frikk
2007-03-13 15:59                 ` Robert A Duff
2007-03-13 16:18                 ` Dmitry A. Kazakov
2007-03-13 16:21                 ` Jeffrey R. Carter
2007-03-13 16:04               ` Adam Beneschan
2007-03-13 16:41                 ` Adam Beneschan
2007-03-13 16:42                   ` Adam Beneschan
2007-03-14 14:06                     ` frikk
2007-03-13 17:23                 ` Dmitry A. Kazakov
2007-03-13 17:31                   ` Adam Beneschan
2007-03-14  0:54                   ` Jeffrey R. Carter
2007-03-16 13:38                   ` frikk
2007-03-13 16:16           ` Jeffrey R. Carter [this message]
2007-03-12 21:04     ` 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