🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c++
Article #3631

Re: 'const' in header files

#3631
From: Lars Farm
Date: Sat, 09 Mar 1996 15:42
42 lines
2463 bytes
In article <4hn54s$3am@engnews1.Eng.Sun.COM>,
clamage@Eng.Sun.COM (Steve Clamage) wrote:

>Next, why single out this one particular optimization?

To kill the #preprocessor.

I do not consider it an optimization. It is not about performance. It is
about semantics. I have viewed X from "const built_in_type X =
some_compiler_generated_value;" as a constant. More or less as some kind of
#define that knows about scope. Perhaps this view is incorrect. It is not a
constant. It is a local variable, but a variable you're not allowed to
alter? 

To me there is a difference in interpretation between constant and
variable. I would like to see that semantic difference reflected in the
standard. I believe that it already is to some extent, but only for integer
types.

const int N = 10;
int arr[N]; // this is not about optimization, is it?

In article <4hqd3e$n7k@news.aosi.com>,
yeager@aosi.com wrote:

>One area where such a requirement conflicts with existing rules would
>be if the constant object has a constructor.  Then the existing rules
>would not allow the constant to be omitted since the constructor must
>be called (especially if it has detectable side effects) even if the
>constant is not used in the particular compilation unit.

I talk about built in types: short, int, float, double, char, etc. Their
constructors do not have any side effects.

--
Lars Farm, lars.farm@nts.mh.se
---
[ comp.std.c++ is moderated.  To submit articles: try just posting with      ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu         ]
[ FAQ:      http://reality.sgi.com/employees/austern_mti/std-c++/faq.html    ]
[ Policy:   http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
[ Comments? mailto:std-c++-request@ncar.ucar.edu                             ]
Technical Details
Message-ID: <AD672E17966850AA2@sleipner.nts.mh.se>
Path: arc1-ca.pugleaf.net!in1.uu.net!bounce-back
References: <AD64B66E966816216@sleipner.nts.mh.se> <4hn54s$3am@engnews1.Eng.Sun.COM>

Show Full Headers
Complete Article Headers
From: lars.farm@nts.mh.se (Lars Farm)
Message-ID: <AD672E17966850AA2@sleipner.nts.mh.se>
X-Original-Date: Sat, 09 Mar 1996 12:46:15 +0100
Path: arc1-ca.pugleaf.net!in1.uu.net!bounce-back
Date: 09 Mar 96 15:42:58 GMT
Approved: fjh@cs.mu.oz.au
Newsgroups: comp.std.c++
Subject: Re: 'const' in header files
Organization: pv
References: <AD64B66E966816216@sleipner.nts.mh.se> <4hn54s$3am@engnews1.Eng.Sun.COM>
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: 8bit
X-Auth: PGPMoose V1.1 PGP comp.std.c++
 iQBFAgUBMUGnDuEDnX0m9pzZAQEI8wF9Gd2rmByQCiXmPc+JLJ92GwzKzUfTWgKZ
 zqdmBY7qqxcKzuCtQV3VNKzZt/wr7wO3
 =kP8+