Article View: comp.lang.functional
Article #216Re: Purity and Laziness
From: Geoff Barrett
Date: Fri, 25 May 1990 09:56
Date: Fri, 25 May 1990 09:56
46 lines
2197 bytes
2197 bytes
In article <4170@castle.ed.ac.uk> nick@lfcs.ed.ac.uk (Nick Rothwell) writes:
>Correct me if I'm wrong (more than likely...) but in a lazy language
>I can write things like
>
> fun f x = cons(1, f x)
>
>to build an infinite list, but not
>
> fun f x = reverse_cons(f x, 1)
>
>because of the reduction order.
If you apply a printing function to the second you might get a "(" on
the screen and then the program will hang, but that is to do with the
strictness of the printing function. It's the printing function which
has defined an evaluation order, in effect. However, if I were to
pattern match
fun last (reverse_cons(x,a)) = a
a call of "last (f x)" should return "1" (BTW, what's that "x" for?).
I believe there is an Oxford DPhil thesis by a man called David Turner
which pointed out that strict languages are not referentially
transparent because of the fact that conditionals are not strict, so
that the equality symbol in the definition
fun iiff (b,x,y) = if b then x else y
is not equality. Lazy evaluation languages are referentially
transparent. I think this is what the original poster meant by
"purer".
> Nick.
>--
>Nick Rothwell, Laboratory for Foundations of Computer Science, Edinburgh.
> nick@lfcs.ed.ac.uk <Atlantic Ocean>!mcsun!ukc!lfcs!nick
>~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~
> Ich weiss jetzt was kein Engel weiss
Geoff Barrett
vvv| |vvv-------------------------------------
\ o o /
\ / Wot! No Queen's Award logo?
Technical Details
Message-ID:
<7044@ganymede.inmos.co.uk>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!mailrus!uwm.edu!zaphod.mps.ohio-state.edu!usc!snorkelwacker!bloom-beacon!eru!luth!sunic!mcsun!ukc!inmos!geoffb@butcombe.inmos.co.ukReferences:
<14531@dime.cs.umass.edu> <2535@skye.ed.ac.uk> <8691@cs.utexas.edu> <4170@castle.ed.ac.uk>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!mailrus!uwm.edu!zaphod.mps.ohio-state.edu!usc!snorkelwacker!bloom-beacon!eru!luth!sunic!mcsun!ukc!inmos!geoffb@butcombe.inmos.co.uk From: geoffb@butcombe.inmos.co.uk (Geoff Barrett) Newsgroups: comp.lang.functional Subject: Re: Purity and Laziness Message-ID: <7044@ganymede.inmos.co.uk> Date: 25 May 90 09:56:09 GMT References: <14531@dime.cs.umass.edu> <2535@skye.ed.ac.uk> <8691@cs.utexas.edu> <4170@castle.ed.ac.uk> Sender: news@inmos.co.uk Reply-To: geoffb@inmos.co.uk (Geoff Barrett) Organization: INMOS Limited, Bristol, UK. Lines: 46