From: John Peterson
Subject: The BEST way to sum a list
Date: 
Message-ID: <7559@megaron.arizona.edu>
The discussion comparing different ways to sum a list has missed an
important point.  Although the solution
  (apply '+ list)
is very elegent, it ignores a basic limitation of Common Lisp: 
call-arguments-limit.  This will not work (nor will eval) if the
list is longer than this value.  CLtL only states this limit must be at
least 50, not much of a list.  To be safe (or at least postable), either the
iterative solution or reduce should be used.  Also, note that this
brings up the issue of whether &rest should provide a freshly consed
list or not.  If it is, &rest would incur the additional overhead of a
list copy.  This issue is not addressed in CLtL.

(There are some very good implementation reasons for this limit.  Using
registers for parameter passing yields dramatic speedup, but only a
finite number of registers or psuedo registers are available.)


    John Peterson
    University of Arizona, Dept of Computer Science
    ···@megaron.arizona.edu

    Think Granite

From: Stephen Knight
Subject: Re: The BEST way to sum a list
Date: 
Message-ID: <1350018@otter.hple.hp.com>
···@arizona.edu (John Peterson) writes:
> The discussion [comparing different ways to sum a list]
> ignores a basic limitation of Common Lisp: call-arguments-limit. 

A very good point!  I would be interested in the typical values of this
system parameter.  Poplog CL has a default call-arguments-limit of 
536870912.  Is this unusual?

> (There are some very good implementation reasons for this limit.  Using
> registers for parameter passing yields dramatic speedup, but only a
> finite number of registers or psuedo registers are available.)

Although this is an explanation, I don't think it is an acceptable 
justification for strange limits like 50.  Sure, there are only a finite 
number of registers.  When they are all used up another parameter passing
mechanism is required.  This does not seem to be especially impractical or
even difficult.

I am reminded of a similar case in Pascal, where the guaranteed maximum size
of a set is something like 64 -- which is a crippling limitation in terms of
guaranteed portability.  In these cases one has to make a choice based on the
actual limits of popular compilers.

Steve Knight
From: Barry Margolin
Subject: call-arguments-limit (Re: The BEST way to sum a list)
Date: 
Message-ID: <30123@think.UUCP>
In article <·······@otter.hple.hp.com> ···@otter.hple.hp.com (Stephen Knight) writes:
>···@arizona.edu (John Peterson) writes:
>> The discussion [comparing different ways to sum a list]
>> ignores a basic limitation of Common Lisp: call-arguments-limit. 
>A very good point!  I would be interested in the typical values of this
>system parameter.  Poplog CL has a default call-arguments-limit of 
>536870912.  Is this unusual?

On a Symbolics Lisp Machine running Genera 7.2 it is 128.

The reason for this limit is that the instructions for accessing
arguments on the stack only have a seven-bit (unsigned) field for
specifying the argument offset.

However, I was able to APPLY #'+ to a 1000-element list because the
mechanism for applying a function with an &REST argument shares the
list that is the last argument to APPLY.  Therefore, the list never
gets copied to the stack, and the function never actually refers to
the arguments positionally.  It's as if the &REST argument were an
ordinary argument and FUNCALL were being used instead of APPLY.

Barry Margolin
Thinking Machines Corp.

······@think.com
{uunet,harvard}!think!barmar
From: Michael R Hall
Subject: Re: The BEST way to sum a list
Date: 
Message-ID: <274@nvuxh.UUCP>
In article <·······@otter.hple.hp.com> ···@otter.hple.hp.com (Stephen Knight) writes:
····@arizona.edu (John Peterson) writes:
=> The discussion [comparing different ways to sum a list]
=> ignores a basic limitation of Common Lisp: call-arguments-limit. 
=
=A very good point!  I would be interested in the typical values of this
=system parameter.  Poplog CL has a default call-arguments-limit of 
=536870912.  Is this unusual?

Sun Lucid Common Lisp Development Environment 2.0.3 has 512 for the
call-arguments-limit value; I would guess that 536870912 is quite
unusual. [How about trying an experiment - call a function in Poplog
CL with 536870912 arguments and then call it with 536870913
arguments and see what happens...]
-- 
Michael R. Hall                               | Bell Communications Research
"I'm just a symptom of the moral decay that's | ··········@bellcore.COM
gnawing at the heart of the country" -The The | bellcore!nvuxh!hall