TEAM-ADA Archives

Team Ada: Ada Programming Language Advocacy

TEAM-ADA@LISTSERV.ACM.ORG

Options: Use Forum View

Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

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

Print Reply
Subject:
From:
Steven Deller <[log in to unmask]>
Reply To:
Steven Deller <[log in to unmask]>
Date:
Tue, 19 Oct 1999 00:47:23 -0400
Content-Type:
text/plain
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