🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.functional
Article #374

Re: side effects in FL's (was "Can laziness sometimes be too lazy?")

#374
From: Robert Harper
Date: Tue, 24 Jul 1990 17:43
47 lines
2794 bytes
jashley@silver.ucs.indiana.edu (J. Michael Ashley) writes:

...

>An exeption is a side effect.  You're playing with the state of the program.
>That's why exception handlers and most every other kind of control structure
>is a no-no in functional languages.  I don't like this, and it's why I will
>never enjoy functional languages, but that's the nature of the beast, and 
>you have to live with it.

ML's approach to exceptions can be arguably considered as related to "side
effects" (due to the dynamic binding of handlers), but it is by no means the
case that control flow constructs are a "no-no" in FL's.  FL's, like any other
languages, have an operational semantics describing the order of evaluation,
and it is perfectly sensible to consider constructs for altering the normal
order (so to speak).  Lazy languages have problems in this area for practical,
not theoretical reasons: under CBN it is difficult to predict when a phrase
will be evaluated, or whether it will be evaluated more than once (this is
connected with the "full laziness" issue.)

>If you *do* want an exception handler, then go look at ML (or maybe SML).
>Bruce Duba worked with Chris Haynes at Indiana University on typing call/cc,
>which is a construct that hands the programmer the current continuation as
>a first-class function.  He went on and is working for whoever does ML and
>has implemented it in the language.  It's now in the standard.

I can't comment authoritatively on the history of the work, but it should be
mentioned that Bruce worked with Andrew Appel and Dave MacQueen on the
addition of call/cc to SML.  It should also be mentioned that callcc is by no
means  a part of the standard.  In fact, my own investigations indicate that
to do so would involve a considerable re-working of the dynamic semantics.

>I agree here.  There's plenty of cases where you have built up a 
>magnificently large continuation and either want to throw it all away and
>return an error or else save it for later and do something else right now.
>That's why first-class continuations are so great.

Just as are goto's in imperative languages.

Robert Harper
School of Computer Science
Carnegie Mellon University
Pittsburgh, PA 15213-3890
USA

ArpaNet: rwh@cs.cmu.edu
Telephone: +1 412 268 3675
Technical Details
Message-ID: <rwh.648841424@PROOF.ERGO.CS.CMU.EDU>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!tut.cis.ohio-state.edu!pt.cs.cmu.edu!PROOF.ERGO.CS.CMU.EDU!rwh
References: <51915@iuvax.cs.indiana.edu>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!tut.cis.ohio-state.edu!pt.cs.cmu.edu!PROOF.ERGO.CS.CMU.EDU!rwh
From: rwh@PROOF.ERGO.CS.CMU.EDU (Robert Harper)
Newsgroups: comp.lang.functional
Subject: Re: side effects in FL's (was "Can laziness sometimes be too lazy?")
Message-ID: <rwh.648841424@PROOF.ERGO.CS.CMU.EDU>
Date: 24 Jul 90 17:43:44 GMT
References: <51915@iuvax.cs.indiana.edu>
Organization: Carnegie-Mellon University, CS/RI
Lines: 47