From: Brian Rogoff <bpr@shell5.ba.best.com>
Subject: Re: Newbie question : types , representation
Date: 1999/08/24
Date: 1999-08-24T00:00:00+00:00 [thread overview]
Message-ID: <Pine.BSF.4.10.9908242009410.3007-100000@shell5.ba.best.com> (raw)
In-Reply-To: 37C2E8BE.40461448@village.uunet.be
On Tue, 24 Aug 1999, Jos De Laender wrote:
> What I do know that in C, I can do all of my operations (shifting,
> anding ..) on chars.
In Ada (we always mean Ada 95 here when we say Ada, a situation unlike the
VHDL world ;-) the package Interfaces contains the Shift_Left,
Shift_Right, and other operations you're looking for, as well as types
like Unsigned_8, Unsigned_16, etc. These are probably what you're looking
for. I rather wish there were operators (<<, >>) for this, as in C, but
it is not a problem, just my syntactic preference. I won't even start
talking about <<= :-)
> It's ugly in the sense that I'm mixing really semantics of chars and
> bytes and integers and whatever. But on compiler output I can expect a
> fairly optimal implementation.
I guess I don't find it (C) that ugly here, but my tastes are my own. C is
a very low level language compared to Ada, so it is to be expected that it
would be this way. C declaration syntax is ugly IMO.
> In ADA , I think (but this was part of the question) , I have to go
> through some tables and through some conversion functions. Although it
> is not necessarily so , there is at least the increased risk of less
> optimal implementation, because the compiler has to find out those
> things. I didn't say this is not possible, I asked how one could write
> it without having this risk.
If you know that characters are the same size as your "byte" type, be it
an Interfaces.Unsigned_8 or a System.Storage_Element then it should be OK
to use Unchecked_Conversion if you're worried about the overhead of a
conversion function, but I really can't imagine any overhead even from a
safe type conversion if you turn checking off, which you really must do if
you want to compare with C. I don't understand why you think there is some
table lookup involved.
Part of the problem with C and Ada comparisons is that every C operation is
unchecked, whereas in Ada everything is checked by default. You have to
know enough about your Ada compiler to turn off those checks when doing
the performance comparisons.
-- Brian
next prev parent reply other threads:[~1999-08-24 0:00 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
1999-08-22 0:00 Newbie question : types , representation Jos De Laender
1999-08-22 0:00 ` Robert Dewar
1999-08-23 0:00 ` Wolfgang Jeltsch
1999-08-24 0:00 ` tmoran
1999-08-24 0:00 ` jdla
1999-08-24 0:00 ` Matthew Heaney
1999-08-24 0:00 ` Jos De Laender
1999-08-24 0:00 ` Brian Rogoff [this message]
1999-08-25 0:00 ` Jos De Laender
1999-08-22 0:00 ` Martin Dowie
1999-08-22 0:00 ` Wilhelm Spickermann
1999-08-23 0:00 ` Simon Wright
1999-08-23 0:00 ` Martin C. Carlisle
[not found] ` <37C621F3.C6C0DC3A@acenet.com.au>
1999-08-27 0:00 ` tmoran
1999-08-27 0:00 ` Florian Weimer
1999-08-27 0:00 ` David C. Hoos, Sr.
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox