From: Erik Naggum
Subject: inlined function calls
Date: 
Message-ID: <3058359104672953@naggum.no>
this is probably a very simple question, but I'd like to have some
assumptions confirmed.

given a form like (mapcar (lambda (<args>) <body>) <list>), is a compiler
free to produce code without any other function calls than those in <body>
(which it may also inline)?  that is, knowing that symbols in the
COMMON-LISP package cannot be redefined, can a compiler fully utilize any
knowledge it may have about the use of functions, even to the point of
"refining" the programmer's implementation as long as it maintains the
semantics?

e.g, can (map nil (lambda (file) <whatever>) (directory <dirspec>)) and
(dolist (file (directory <dirspec>)) <whatever>) produce exactly the same
code?

I believe this should be possible, but then there are all sorts of problems
in debugging and tracing Lisp programs which may have caused somebody not
to allow it.  (I can't find anything either way in the standard.)

#\Erik
-- 
Please address private replies, only, to "erik".  Junk mail, spam,
stupid flames, courtesy copies, etc, should be sent to "nobody".
From: Barry Margolin
Subject: Re: inlined function calls
Date: 
Message-ID: <57rj70$irl@tools.bbnplanet.com>
In article <················@naggum.no>, Erik Naggum  <······@naggum.no> wrote:
>e.g, can (map nil (lambda (file) <whatever>) (directory <dirspec>)) and
>(dolist (file (directory <dirspec>)) <whatever>) produce exactly the same
>code?

Yes.

>I believe this should be possible, but then there are all sorts of problems
>in debugging and tracing Lisp programs which may have caused somebody not
>to allow it.  (I can't find anything either way in the standard.)

The standard doesn't say anything about how easy it is to debug things,
that's a quality of implementation issue.  Since there's no way in the
language to tell whether a lambda expression has been inlined or not,
there's nothing prohibiting a compiler from doing so.  And I believe some
compilers will do so.

In practice, I would expect a high DEBUG optimize setting to prevent such
inlining.
-- 
Barry Margolin
BBN Planet, Cambridge, MA
······@bbnplanet.com -  Phone (617) 873-3126 - Fax (617) 873-5508
(BBN customers, please call (800) 632-7638 option 1 for support)