🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: constness of private members and methods

#3946
From: Joe Buck
Date: Sat, 06 Apr 1996 19:33
36 lines
2506 bytes
jdmorris@ix.netcom.com (Jason D. Morris) wrote:
>>Assuming you allow 'pure' and 'clean', the compiler would then have
>>to check to make sure your functions were in fact 'pure' and 'clean'.

abell@mindspring.com (Andrew Bell) writes:
>The problem is the compiler needs to know the "purity" of the
>functions a given function calls during its compilation, or it can't
>optimize the code.  You would thus have to compile all the called
>functions first,

No, you wouldn't.  Think of contractual programming, as in Eiffel.
If a keyword associated with a prototype makes a promise (e.g. that
a function has no side effects), users of that function can assume
that promise is kept.  When the compiler compiles the "pure function",
only then does it need to check the function for purity, using only
local information.  No complex analysis is required: any function
calls not so tagged would be assumed to be impure.

>With the proposed idea, a function that claims to pure and isn't would
>be tagged with a compiler error.  This might be problematic with
>templates, as instantiation for a particular type may lead to non-pure
>functions being called.

Replace "pure" with "const".  It's no different.
-- 
-- Joe Buck 	<jbuck@synopsys.com>	(not speaking for Synopsys, Inc)

Work for something because it is good,
not just because it stands a chance to succeed.	   -- Vaclav Havel
---
[ comp.std.c++ is moderated.  To submit articles: Try just posting with your 
                newsreader.  If that fails, use mailto:std-c++@ncar.ucar.edu
  comp.std.c++ FAQ: http://reality.sgi.com/austern/std-c++/faq.html
  Moderation policy: http://reality.sgi.com/austern/std-c++/policy.html
  Comments? mailto:std-c++-request@ncar.ucar.edu 
]
Technical Details
Message-ID: <4k3q10$7bd@hermes.synopsys.com>
Path: arc1-ca.pugleaf.net!fido.asd.sgi.com!austern
References: <m0u3992-000GcEC@7.kurahaupo.gen.nz> <3161eaa4.8216104@nntp.ix.netcom.com> <4jvcrn$ch2@mule1.mindspring.com>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!fido.asd.sgi.com!austern
From: jbuck@Synopsys.COM (Joe Buck)
Newsgroups: comp.std.c++
Subject: Re: constness of private members and methods
Date: 06 Apr 1996 11:33:45 PST
Organization: Synopsys Inc., Mountain View, CA 94043-4033
Approved: austern@isolde.mti.sgi.com
Message-ID: <4k3q10$7bd@hermes.synopsys.com>
References: <m0u3992-000GcEC@7.kurahaupo.gen.nz> <3161eaa4.8216104@nntp.ix.netcom.com> <4jvcrn$ch2@mule1.mindspring.com>
NNTP-Posting-Host: isolde.mti.sgi.com
X-Original-Date: 5 Apr 1996 18:50:08 GMT
X-Auth: PGPMoose V1.1 PGP comp.std.c++
 iQBVAwUBMWbHGky4NqrwXLNJAQFypgH8Dfhvx7gaLVb4kTo0FkhEzGVfvwU0VK4E
 SYMrC3ta+P3KaEOriNiQTbGKm7eqW0sAlzBBOk91+D8Pvl+MEL/mVA==
 =hTM+
Originator: austern@isolde.mti.sgi.com