comp.lang.ada
 help / color / mirror / Atom feed
* Two more AQS-95 questions
@ 1998-02-02  0:00 Wes Groleau
  1998-02-03  0:00 ` Robert Dewar
  1998-02-05  0:00 ` K. E. Garlington
  0 siblings, 2 replies; 4+ messages in thread
From: Wes Groleau @ 1998-02-02  0:00 UTC (permalink / raw)



1)  In 3.2.6, why "use a constant ... when the value must be static"
    but "named numbers, ... whenever possible."  Isn't a named number
    static?  Is there an advantage to a (typed) constant for 
    "staticness" ?

2.  (Re: end of preface) the first comment address bounced.
    I'm CC'ing this to the other listed address, but if that
    bounces, can someone from AJPO or SPC provide an alternative?

-- 
--------------------------------------------------------------------
    Wes Groleau, Raytheon Systems Company, Fort Wayne, IN USA
  Member of Technical Staff - AFATDS        Tool-smith Wanna-be
                wwgrol AT pseserv3.fw.hac.com
     Don't send advertisements to this domain unless asked!
      All disk space on fw.hac.com hosts belongs to either
   Raytheon Systems Company or the United States government.
  Using email to store YOUR advertising on them is trespassing!
--------------------------------------------------------------------




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Two more AQS-95 questions
  1998-02-02  0:00 Two more AQS-95 questions Wes Groleau
@ 1998-02-03  0:00 ` Robert Dewar
  1998-02-05  0:00 ` K. E. Garlington
  1 sibling, 0 replies; 4+ messages in thread
From: Robert Dewar @ 1998-02-03  0:00 UTC (permalink / raw)



Wes says


<<1)  In 3.2.6, why "use a constant ... when the value must be static"
    but "named numbers, ... whenever possible."  Isn't a named number
    static?  Is there an advantage to a (typed) constant for
    "staticness" ?
>>


This is totally incorrect advice. Not just harmless, but actively harmful.

Named numbers are untyped. Their use is only appropriate if from a
conceptual point of view, the constant value *is* untyped, for example

  pi : constant := 3.14....

is OK, because conceptually pi is an untyped pure number.

If a constant is typed, then it is definitely MUCH more desirable to
type the constant, so that you get proper type checking on its use.





^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Two more AQS-95 questions
  1998-02-02  0:00 Two more AQS-95 questions Wes Groleau
  1998-02-03  0:00 ` Robert Dewar
@ 1998-02-05  0:00 ` K. E. Garlington
  1998-02-05  0:00   ` Robert Dewar
  1 sibling, 1 reply; 4+ messages in thread
From: K. E. Garlington @ 1998-02-05  0:00 UTC (permalink / raw)



Wes Groleau wrote:
> 
> 1)  In 3.2.6, why "use a constant ... when the value must be static"
>     but "named numbers, ... whenever possible."  Isn't a named number
>     static?  Is there an advantage to a (typed) constant for
>     "staticness" ?

Just for the record, the rationale given for using a named number
instead of a constant is:

"Named numbers allow compilers to generate more efficient code than for
constants and to perform more complete error checking at compile time."

I've seen the efficiency effect sporadically (not enough to use it as
justification in this case); how the error checking advantage accrues is
beyond me.

I wonder if this is just a misinterpretation of another rule in the set;
that it's sometimes better to write a constant declaration in terms of
an equation of named numbers rather than a single literal?




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Two more AQS-95 questions
  1998-02-05  0:00 ` K. E. Garlington
@ 1998-02-05  0:00   ` Robert Dewar
  0 siblings, 0 replies; 4+ messages in thread
From: Robert Dewar @ 1998-02-05  0:00 UTC (permalink / raw)



<<"Named numbers allow compilers to generate more efficient code than for
constants and to perform more complete error checking at compile time."
>>

I would find it surprising if any compiler generated more efficient
code for the named number case. I mean I suppose you could imagine
a compiler so broken that it would only do constant propagating for
named numbers, but that would sure be surprising. Certainly for GNAT
there is no such advantage, and hypotheisizing such an advantage in
a style guide seems nonsense to me.

For sure, the point about more complete error checking is wrong. Indeed,
this is a case in which there is indeed a difference, but it is the
other way round, a typed constant obviously gives more opportunities for
type checking!





^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~1998-02-05  0:00 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1998-02-02  0:00 Two more AQS-95 questions Wes Groleau
1998-02-03  0:00 ` Robert Dewar
1998-02-05  0:00 ` K. E. Garlington
1998-02-05  0:00   ` Robert Dewar

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