TEAM-ADA Archives

Team Ada: Ada Programming Language Advocacy

TEAM-ADA@LISTSERV.ACM.ORG

Options: Use Classic View

Use Monospaced Font
Show HTML Part by Default
Condense Mail Headers

Topic: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Sender: "Team Ada: Ada Advocacy Issues (83 & 95)" <[log in to unmask]>
X-To: 'Ohlund Magnus' <[log in to unmask]>
Date: Tue, 19 Oct 1999 00:47:23 -0400
Reply-To: Steven Deller <[log in to unmask]>
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Type: text/plain; charset="us-ascii"
From: Steven Deller <[log in to unmask]>
Parts/Attachments: text/plain (35 lines)
On Monday, October 18, 1999 9:08 AM, Ohlund Magnus
[SMTP:[log in to unmask]] wrote:
> Hi,
>
> I wonder if the Rational compiler is smart enough to understand that for
> example in the following expression
>
> Tmp : Integer;
>
> Tmp := Tmp + 2**4;
>
> the compiler will understand that 2**4 is a constant ( =16 ) and replace
> the
> calculation with its value ( = 16 ).

Yes the Rational compiler is smart enough to do constant folding (and a lot
more).

But the approach of defining all such constants as a named number, giving it
some descriptive name is a good one.  It is far easier to read:
  One_Degree_Fahrenheit : constant := 2**4 ;
  ...
  Tmp := Tmp + One_Degree_Fahrenheit ;

than is to read and understand why there is some particular constant in your
program.

Regards,
Steve

Steven Deller, Apex Ada Marketing
[log in to unmask], (410) 757 6924
Rational Software Corporation, http://www.rational.com
For user email groups, check  http://www.rational.com/support/newsgroup

ATOM RSS1 RSS2