Newsgroups: comp.lang.scheme,comp.lang.functional
Path: cantaloupe.srv.cs.cmu.edu!nntp.club.cc.cmu.edu!hudson.lm.com!news.pop.psu.edu!news.cac.psu.edu!howland.reston.ans.net!gatech!swrinde!ihnp4.ucsd.edu!munnari.oz.au!cs.mu.OZ.AU!munta.cs.mu.OZ.AU!fjh
From: fjh@munta.cs.mu.OZ.AU (Fergus Henderson)
Subject: Re: when to use state?
Message-ID: <9500305.10018@mulga.cs.mu.OZ.AU>
Sender: news@cs.mu.OZ.AU
Organization: Computer Science, University of Melbourne, Australia
References: <3dfv8i$ifp@nkosi.well.com> <9436516.26620@mulga.cs.mu.OZ.AU> <3e45ts$9e@agate.berkeley.edu> <9500118.16942@mulga.cs.mu.OZ.AU> <3e6lji$n7i@agate.berkeley.edu>
Date: Mon, 2 Jan 1995 18:29:26 GMT
Lines: 24
Xref: glinda.oz.cs.cmu.edu comp.lang.scheme:11677 comp.lang.functional:5469

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

>fjh@munta.cs.mu.OZ.AU (Fergus Henderson) writes:
>>	(2) Ease & efficiency of implementation
>>
>>		In general, checking is easier than inference,
>>		especially when you start talking about separate compilation.
>
>Sorry, but I still don't get it.  Why can't the compiler just pretend
>that everything was declared pure, and then check which ones turn out
>to be wrong?

The problem is that impurity propagates up the call tree.
Suppose that function f in module F calls function g in module G
which calls function H in module H, which contains some "impure" code.
So first off we assume that everything is pure, and check which ones
turn out to be wrong.  The only one that is wrong is function h.
But we can't just mark h as impure and be done with it, becauses g's
purity depends on h's, and f's in turn depends on g's.
So we have to do a fixpoint calculation or some other form of global
analysis.

-- 
Fergus Henderson - fjh@munta.cs.mu.oz.au
