Newsgroups: comp.lang.scheme,comp.lang.functional
Path: cantaloupe.srv.cs.cmu.edu!das-news2.harvard.edu!news2.near.net!howland.reston.ans.net!news.sprintlink.net!hookup!olivea!charnel.ecst.csuchico.edu!csusac!csus.edu!netcom.com!bakul
From: bakul@netcom.com (Bakul Shah)
Subject: Re: when to use state?
Message-ID: <bakulD1p2L5.9EM@netcom.com>
Organization: NETCOM On-line Communication Services (408 261-4700 guest)
References: <3dfv8i$ifp@nkosi.well.com> <ROCKWELL.94Dec28104921@nova.umd.edu> <JDONHAM.94Dec28135842@hadron.us.oracle.com> <9436516.26620@mulga.cs.mu.OZ.AU> <3e45ts$9e@agate.berkeley.edu>
Date: Sat, 31 Dec 1994 21:34:17 GMT
Lines: 23
Xref: glinda.oz.cs.cmu.edu comp.lang.scheme:11672 comp.lang.functional:5464

bh@anarres.CS.Berkeley.EDU (Brian Harvey) writes:

>fjh@munta.cs.mu.OZ.AU (Fergus Henderson) writes:
>>	(1) The compiler can warn if the programmer fails to declare
>>	    a side-effect free function as "pure".

>This is probably a stupid question, but if the compiler can figure that
>out by itself, why should I have to declare it in the first place?

Separate compilation.  If a function is declared pure, the
compiler can flag if it uses any impure functions.  But if
a used function is in a separate module, the compiler can
not easily find out if it is pure.  One can perhaps
generate all that information by making compilers (&
linkers) smarter.  Even so, declaring a function pure may
be desirable if you think of a declaration (or really, an
interface) as a contract between the users and the
implementor(s) of that interface.  To be sure, this
`contract' is imperfect but the more you can mechanically
check, the better.  Of course, Scheme does not have this
problem :-)

Bakul Shah
