From: Adrien Plisson <aplisson-news@stochastique.net>
Subject: Character'First, ASCII.NUL and others (Was: Re: TCP/IP Sockets with GNAT.Sockets)
Date: Wed, 04 May 2005 10:01:49 +0200
Date: 2005-05-04T10:01:49+02:00 [thread overview]
Message-ID: <42788175$0$7747$ba620e4c@news.skynet.be> (raw)
In-Reply-To: <42777609$0$142$edfadb0f@dread11.news.tele.dk>
Poul-Erik Andreasen wrote:
> When i started developing job i tried with ASCII.NUL
> things didn't work out(surely for som other reason);
> they did when i first was using character'first.
> (also surely for som other reason);
>
> Are there any reason why ASCII.NUL should be better;
Character'First do not describe the NUL character. i mean, it is the
NUL character, but you have to know the implementation details of type
Character to see that it's first element is the NUL character.
ASCII.NUL states explicitly that you are using the NUL character,
that's why its use should be better.
anyway, the package ASCII is described in ARM95 J.5, that means it is
part of "Obsolescent Features". as said in the ARM, "Use of these
features is not recommended in newly written programs.". so it is
better than Character'First, but there exists a better way to write this.
the better way is the use of Ada.Characters.Latin_1, which defines a
constant NUL describing the NUL character. unfortunately, the package
name is long, so you may have to write a use clause or a rename.
with Ada.Text_IO,
Ada.Characters.Latin_1;
procedure Test is
-- see comments below
use Ada.Characters.Latin_1;
package ASCII renames Ada.Characters.Latin_1;
package Characters renames Ada.Characters.Latin_1;
begin
Ada.Text_IO.Put( Ada.Characters.Latin_1.NUL ); -- a bit long
Ada.Text_IO.Put( NUL ); -- a bit short, NUL what ?
-- NUL Character ? not sure...
Ada.Text_IO.Put( ASCII.NUL ); -- not recommended, there is
-- a risk of confusion
Ada.Text_IO.Put( Characters.NUL ); -- this seems better !
end Test;
besides all this, when looking at Ada.Characters.Latin_1, we see that
NUL is defined this way :
NUL : constant Character := Character'Val(0);
so if you just need NUL and want to avoid declarations, you may use
Character'Val(0), which describes the NUL character better than
Character'First.
--
rien
next prev parent reply other threads:[~2005-05-04 8:01 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-05-02 2:42 TCP/IP Sockets with GNAT.Sockets fabio de francesco
2005-05-02 5:58 ` Eric Jacoboni
2005-05-02 12:11 ` Adrien Plisson
2005-05-02 14:55 ` fabio de francesco
2005-05-02 16:10 ` Adrien Plisson
2005-05-02 17:56 ` Eric Jacoboni
2005-05-02 18:30 ` Poul-Erik Andreasen
2005-05-02 19:10 ` Simon Wright
2005-05-03 13:00 ` Poul-Erik Andreasen
2005-05-03 21:48 ` Simon Wright
2005-05-04 8:01 ` Adrien Plisson [this message]
2005-05-04 13:40 ` Character'First, ASCII.NUL and others (Was: Re: TCP/IP Sockets with GNAT.Sockets) Poul-Erik Andreasen
2005-05-02 20:37 ` TCP/IP Sockets with GNAT.Sockets fabio de francesco
2005-05-02 20:52 ` Adrien Plisson
2005-05-03 12:04 ` fabio de francesco
2005-05-03 12:22 ` Adrien Plisson
2005-05-03 13:17 ` Poul-Erik Andreasen
2005-05-02 20:44 ` Adrien Plisson
2005-05-02 22:10 ` Eric Jacoboni
2005-05-02 23:42 ` tmoran
2005-05-02 19:39 ` Björn
2005-05-02 20:22 ` fabio de francesco
2005-05-09 4:03 ` Dave Thompson
[not found] <mailman.112.1115585537.24457.comp.lang.ada@ada-france.org>
2005-05-09 20:59 ` Character'First, ASCII.NUL and others (Was: Re: TCP/IP Sockets with GNAT.Sockets) Manuel G. R.
-- strict thread matches above, loose matches on Subject: below --
2005-05-15 2:42 Frank Beard
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox