Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!wuarchive!zaphod.mps.ohio-state.edu!caen!umich!yale!cmcl2!lanl!beta.lanl.gov!scp From: scp@acl.lanl.gov (Stephen C. Pope) Newsgroups: comp.lang.c++ Subject: Re: [SUMMARY] Three ways to declare a function "const" in C++ 2.0 Message-ID: Date: 17 Oct 90 16:04:05 GMT References: Sender: news@lanl.gov Reply-To: scp@acl.lanl.gov Distribution: comp Organization: Advanced Computing Lab, LANL, NM Lines: 34 In-reply-to: ngo@tammy.harvard.edu's message of 16 Oct 90 14:26:25 GMT on 16 Oct 90 14:26:25 GMT, ngo@tammy.harvard.edu (Tom Ngo) said: [...] ngo> In g++, you can declare a function "const", e.g. ngo> const double sin( double x ) [...] Tom> [GNU] The "const" syntax is co-opted to mean something else. It Tom> now declares something about the function itself: that if the Tom> function is called twice, and the arguments are not altered Tom> between calls, the second call to the function can be eliminated Tom> without changing the meaning of the program. This kind of const Tom> is used to eliminate redundant calculations in a sequence like [...] Tom> Tony Hansen remarked: Tom> It's a relatively new extension of g++. I'm sure that it will be Tom> considered by the ANSI committee. I'm also sure that Bjarne Tom> Stroustrup has looked at the extensions that g++ provides, but I Tom> don't think any of them have made it back into C++ in the same Tom> fashion that g++ implemented them. Only thing is, g++ doesn't always do anything with it; this is especially true of virtual methods. Word is that this g++ extension is going away...! stephen pope advanced computing lab, lanl scp@acl.lanl.gov