Newsgroups: comp.lang.scheme
Path: cantaloupe.srv.cs.cmu.edu!das-news2.harvard.edu!oitnews.harvard.edu!yale!gumby!newsxfer.itd.umich.edu!ncar!uchinews!not-for-mail
From: cdjeris@midway.uchicago.edu (Christopher Jeris)
Subject: MIT Scheme map function evaluates back to front?
X-Nntp-Posting-Host: quads.uchicago.edu
Message-ID: <DrDp66.5Fy@midway.uchicago.edu>
Sender: news@midway.uchicago.edu (News Administrator)
Organization: The University of Chicago
Date: Tue, 14 May 1996 04:44:30 GMT
Lines: 22

I discovered recently (while working on some code from Essentials of
Programming Languages, which I think is a *wonderful* book, if any of
its authors are lurking) that the `map' function in MIT Scheme 7.4
appears to evaluate its arguments back to front.  To wit:

(map (lambda (x) (display x)) '(a b c d e))

results in `edcba' being printed (followed by a list of five unspecified
return values, of course) rather than the expected `abcde'.  SCM 4e3
prints `abcde'.  Now I'm not objecting to this behavior---I know that the
order of evaluation of the arguments to `map' is unspecified, and that
`for-each' is provided for people who want side-effects and an evaluation
order they can rely on.  I'm just curious:  Why is it done this way?

(Incidentally, under scheme font-lock-mode in Emacs 19.30, `map' gets
printed in the special-form color even though it's a procedure, while
`set!' is printed in the procedure (i.e. ordinary) color even though
it's a special form.  Is this a deliberate decision, and is it related
to the implementation of map in MIT Scheme?)

Christopher Jeris	c-jeris@uchicago.edu	University of Chicago Math!
Languages of choice:  Scheme ML Modula-3 / End the carnage.  Ban C++ now.
