From: micronian2@gmail.com
Subject: Re: Problem using Ada.Text_IO.Modular_IO
Date: Mon, 14 Jul 2008 09:34:34 -0700 (PDT)
Date: 2008-07-14T09:34:34-07:00 [thread overview]
Message-ID: <85edeb59-f2aa-465d-9fac-ffd7ba839a5d@s50g2000hsb.googlegroups.com> (raw)
In-Reply-To: 1215965011.20645.42.camel@K72
Hi,
In the context of using types such as Unsigned_N from Interfaces, what
if you needed the bit shifting operations? From looking at the RM,
they are only available for modular types defined in Interfaces:
Ada2005 RM2.5.4(28)
The same arithmetic operators are predefined for all signed integer
types defined by a signed_integer_type_definition (see 4.5, “Operators
and Expression Evaluation”). For modular types, these same operators
are predefined, plus bit-wise logical operators (and, or, xor, and
not). In addition, for the unsigned types declared in the language-
defined package Interfaces (see B.2), functions are defined that
provide bit-wise shifting and rotating.
Of course, a good compiler would probably translate something like
2**X into a shift which is great. But what about
Shift_Arithmetic_Right or Rotate_Left? If I had to define my own, then
it probably would not be as efficient as a predefined one from
Interfaces. It would have been nice if the Ada standard guaranteed
such operations were available for user-defined modular types.
--Micronian Coder
On Jul 13, 9:03 am, Georg Bauhaus <rm.plus-
bug.t...@maps.futureapps.de> wrote:
> On Sun, 2008-07-13 at 00:51 +0000, anon wrote:
> > Plus, when a programmer defines their own type in Ada, Ada adds
> > extra set of routines that are not based in hardware checks but software,
> > which slows a program down.
>
> I'm not sure there is some real context here. There is no loss
> in speed and no cost in terms of additional checks for using
> either Unsigned_64 or "mod 2**64". (Or "mod 2**(something smaller)".)
> Below is an example to serve as one of many (really unnecessary)
> proofs that there is no overhead stemming from user defined types
> "mod 2**N". (And no overhead stemming from user defined types
> in general---they are there for a reason in this real-time
> systems programming language, I should think.)
>
[Example code removed]
next prev parent reply other threads:[~2008-07-14 16:34 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-07-09 16:52 Problem using Ada.Text_IO.Modular_IO jujosei
2008-07-09 19:03 ` Anh Vo
2008-07-09 19:22 ` Adam Beneschan
2008-07-09 21:50 ` Adam Beneschan
2008-07-10 15:00 ` jujosei
2008-07-10 0:48 ` anon
2008-07-10 1:52 ` Adam Beneschan
2008-07-10 7:25 ` anon
2008-07-10 14:59 ` Adam Beneschan
2008-07-11 0:34 ` anon
2008-07-11 9:49 ` Georg Bauhaus
2008-07-11 10:05 ` christoph.grein
2008-07-11 13:21 ` John McCormick
2008-07-11 12:16 ` anon
2008-07-11 13:26 ` petter_fryklund
2008-07-11 21:10 ` anon
2008-07-12 10:06 ` Georg Bauhaus
2008-07-13 0:51 ` anon
2008-07-13 16:03 ` Georg Bauhaus
2008-07-14 2:03 ` anon
2008-07-14 13:12 ` Georg Bauhaus
2008-07-16 6:16 ` micronian2
2008-07-16 7:47 ` anon
2008-07-17 16:33 ` micronian2
2008-07-14 16:34 ` micronian2 [this message]
2008-07-14 17:26 ` Georg Bauhaus
2008-07-16 6:28 ` micronian2
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox