Newsgroups: comp.lang.scheme,comp.lang.lisp
Path: cantaloupe.srv.cs.cmu.edu!rochester!udel!news.mathworks.com!newsfeed.internetmci.com!tank.news.pipex.net!pipex!dispatch.news.demon.net!demon!uknet!newsfeed.ed.ac.uk!festival!jeff
From: jeff@festival.ed.ac.uk (J W Dalton)
Subject: Re: Confused over Scheme Pedagogy of mutation procedures
References: <RICHTER.95Jul19084033@banach.math.purdue.edu> <pch-1907951304510001@m142.mystech.com>
Message-ID: <DCqsq6.M8A@festival.ed.ac.uk>
Organization: Edinburgh University
Date: Thu, 3 Aug 1995 16:06:05 GMT
Lines: 54
Xref: glinda.oz.cs.cmu.edu comp.lang.scheme:13412 comp.lang.lisp:18535

pch@mystech.com (Pete Halverson) writes:

>In article <RICHTER.95Jul19084033@banach.math.purdue.edu>,
>richter@banach.math.purdue.edu (Bill Richter) wrote:

>> The code below [SICP,p 171] is claimed to be confusing
>> 
>> (S!S)    (define new-withdraw
>>            (let ((balance 100))
>>              (lambda (amount)
>>                ...)))
> ....     
>> I say what's confusing here is that `make-withdraw' is now a
>> function that returns functions, which can have lexically apparent
>> extern declarations preceding them!
>> 
>> OK, that's a mind-boggling abstraction.  But why not?  Lisp is
>> supposed to be good for that kind of thing, that's supposed to be the
>> advantage of the idea that "everything is a symbolic expression."
>> 
>> But my belief is that you cannot this in Lisp. 

>It's not clear what's meant by "Lisp" in these and other similar
>references, as distinct from Scheme, Emacs Lisp, and Common Lisp (all of
>which are mentioned separately).  As you point out, Scheme allows you to
>create functional objects that refer to lexical bindings outside the
>function definition, usually referred to as "lexical closures" (they
>"close over" or "capture" the bindings, even after the function that
>originally set up the bindings has returned).  Common Lisp also supports
>this (albeit with a somewhat klunkier calling form) [...]

>Emacs Lisp does not support this, though, having only dynamic (vs.
>lexical) bindings.

>Or did you really mean Common Lisp?  There's no single language called
>"Lisp"; it's more like a family of languages, members of which include
>Scheme, CL, ELisp, LeLisp, Zetalisp, MacLisp, Dylan (!), ... which share a
>number of core language features and (except for Dylan) similar-looking
>syntaxes.  Some of these support lexical closures, some don't.

Just so.  Moreover, most of the common claims about "Lisp" are wrong.

It may be worth noting, by the way, that a Lisp that has only dynamic
binding might nonetheless be able to create closure objects that can
implement the account example above, lazy lists, and so forth.
Indeed, the dynamically scoped subset of Lisp 1.5 is such a Lisp.

How can that be?  Well, imagine an interpreter for a dynamically
scoped Lisp.  Suppose the interpreter uses an a-list to store
variable bindings.  The closure simply includes the entire a-list.
That's what "funargs" are in Lisp 1.5.

-- jeff

