Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!snorkelwacker!apple!agate!pasteur!baobab.berkeley.edu!twagner From: twagner@baobab.berkeley.edu (Tim Wagner) Newsgroups: comp.lang.c++ Subject: Re: const Message-ID: <27503@pasteur.Berkeley.EDU> Date: 5 Sep 90 21:59:30 GMT References: <10863@cadillac.CAD.MCC.COM> Sender: news@pasteur.Berkeley.EDU Reply-To: twagner@baobab.berkeley.edu (Tim Wagner) Lines: 26 In article <10863@cadillac.CAD.MCC.COM>, vaughan@puma.cad.mcc.com (Paul Vaughan) writes: |> |> Awhile back I posted a message asking if const was really worth the |> trouble. Everyone who replied either on the net or privately thought |> that making a program const correct was indeed worth the effort. |> These were all pretty subjective opinions--it's kind of hard to |> measure how much difference it makes. |> |> So, here's a const question. |> [deleted] This points out once again the problems inherent in C's (and therefore C++'s) use of 'const'. The return type of the function is not a good mechanism in this case: obviously, one cannot really alter the returned value anyhow, so calling it 'const' is redundant. However, the context in which that returned value is used should be controlled; that is, an lvalue getting such a returned object should be const itself. That brings us to the problem of "really constant" versus "sometimes contstant" which has already been beaten to death (by me and others--see back issues for more). In other words, you're right; it's ugly and broken. Tim Wagner twagner@sequoia.Berkeley.EDU