comp.lang.ada
 help / color / mirror / Atom feed
From: Maciej Sobczak <see.my.homepage@gmail.com>
Subject: Re: Ada Recursion with strings
Date: Thu, 2 Oct 2008 23:54:23 -0700 (PDT)
Date: 2008-10-02T23:54:23-07:00	[thread overview]
Message-ID: <6e76ea5c-8bca-4c22-b561-87d2039d8924@m36g2000hse.googlegroups.com> (raw)
In-Reply-To: 758a1a91-7521-4ad3-9af0-a79d434ae60e@v28g2000hsv.googlegroups.com

On 1 Paź, 16:29, Adam Beneschan <a...@irvine.com> wrote:

> > Bits_Per_Byte   : constant := 8;
> > Values_Per_Byte : constant := 2 ** Bits_Per_Byte;
>
> Yep, the advantage of that is that if the people who design the
> Internet communication protocols suddenly decide that IP addresses are
> going to use 9-bit bytes, all you have to do is change one constant,
> rather than try to find all the 8's in your code and change them,
> which is more error-prone.

The people who design the Internet communication protocols will
*never* decide that IP addresses are going to use 9-bit bytes, exactly
because those tons of software that use 8's in the code. Note also
that the majority of software cannot be recompiled because the source
code is not available or just missing.

I agree that constants should be named, but even most strict coding
standards allow several literals to be unnamed and the smallest set is
0 and 1. I think that 2 and 8 are on the border of acceptance too.

So:

Buffer_Size := Get_Buffer_Size_In_Bytes;
Buffer_Bits := Buffer_Size * 8;

Is there any benefit from making the above more verbose with
additional named constant?
Or would it be confusing to anyone to see literal 8 (or some formula
that is build around it) in representation clause? I don't think so.

--
Maciej Sobczak * www.msobczak.com * www.inspirel.com

Database Access Library for Ada: www.inspirel.com/soci-ada



  parent reply	other threads:[~2008-10-03  6:54 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-09-30 20:30 Ada Recursion with strings Joe
2008-09-30 22:24 ` Adam Beneschan
2008-09-30 22:24 ` Jeffrey R. Carter
2008-10-01  0:13   ` Joe
2008-10-01  0:27     ` Jeffrey R. Carter
2008-10-01  1:15       ` Robert A Duff
2008-10-01 11:34         ` Jeffrey R. Carter
2008-10-01 14:29           ` Adam Beneschan
2008-10-01 15:18             ` Jean-Pierre Rosen
2008-10-01 16:47               ` Georg Bauhaus
2008-10-02  7:24               ` Niklas Holsti
2008-10-02  8:18                 ` Ludovic Brenta
2008-10-03  6:54             ` Maciej Sobczak [this message]
2008-10-03  7:38               ` Jean-Pierre Rosen
2008-10-03  9:06               ` Dmitry A. Kazakov
2008-10-01  0:28     ` Adam Beneschan
2008-10-01  9:48       ` Georg Bauhaus
2008-10-01 10:22         ` Dmitry A. Kazakov
2008-10-01  3:01 ` anon
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox