Subject: Re: Tail recursion & CL
From: Erik Naggum <erik@naggum.net>
Date: Sun, 21 Oct 2001 01:22:54 GMT
Newsgroups: comp.lang.lisp
Message-ID: <3212616172232851@naggum.net>

* Frode Vatvedt Fjeld <frodef@acm.org>
| What if? The compiler must deal with macros and compiler-macros
| regardless, and I don't see how they come into play here.

  The questions I have tried in vain to raise are: How much knowledge do
  you require to be able to use your idea productively?  What does it mean
  to employ your suggested form around another form?

  Common Lisp does not, in fact, provide you with any information how a
  particular form will be compiled.  A function call may be inlined, which
  you may defeat with your desire for a tail-call-merging request, it may
  be turned into several function calls, most anything can happen between
  source and machine code.  Therefore, if your idea is not able to
  encompass an entire function's body, it is completely useless, because it
  may _have_ to encompass an entire function's body even if you think you
  are giving it a function call.  If you really want to tell your compiler
  that an _actual_ function call should be tail-call merged, you first have
  to know if your compiler will actually generate a non-merged function
  call that _could_ be a merged tail call.

  In other words, it is an idea that fits languages that do not do anything
  "interesting" with the code they compile.  Instead of providing something
  useful, such as important information for your compiler, you are instead
  limiting your compiler's ability to do interesting things with your code.

  If you want to do something useful by changing the language, I suggest
  finding/inventing ways to tell your compiler that you promise never to
  change the definition of some functions, classes, methods, whatever.
  That kind of information would be tremendously useful to the compiler,
  because it can make assumptions that it cannot make today and which
  necessarily means less opportunity for some kinds of optimization.

///
-- 
  Norway is now run by a priest from the fundamentalist Christian People's
  Party, the fifth largest party representing one eighth of the electorate.
-- 
  The purpose of computing is insight, not numbers.   -- Richard Hamming