more build problems, STEP-FUN in LOOP must be a function
Subject: more build problems, STEP-FUN in LOOP must be a function
From: Raymond Toy
Date: Fri, 04 May 2007 13:44:46 -0400
Andreas Eder wrote:
> Raymond wrote:
>
>> Andreas Eder wrote:
>>> Rainer wrote:
>>>
>>>> Maxima 5.12.0
>>>>
>>>>
>>>> I see code like this:
>>>>
>>>>
>>>> ratmac.lisp
>>>>
>>>> (defmacro pt-red (terms) `(cddr ,terms))
>>>>
>>>>
>>>>
>>>> rat3a.lisp
>>>>
>>>> (defun pctimes1 (c terms)
>>>> (loop for (exp coef) on terms by #'pt-red
>>>> unless (pzerop (setq coef (ptimes c coef)))
>>>> nconc (list exp coef)))
>>>>
>>>>
>>>>
>>>> ANSI Common Lisp defines the STEP-FUN in LOOP
>>>> to be a function. We cannot use a macro here.
>>> Corrected in cvs.
>> I disagree with your fix. Wouldn't the right solution be to make pt-red
>> a inline function? Then the issue is fixed everywhere. I don't know
>> what pt-red really means, but it seems clear that the original author(s)
>> were trying to abstract out the representation, and I don't think we
>> should remove that abstraction.
>
> Yes, pt-red is a kind of abstraction for data access, but in the
> loop code it was used inappropriately. Look at the code mentioned
> above: it loops on a list in pairs, so the step is just by cddr.
> That's natural and obvious - no data access.
>
> So I still think the fix was right.
That still breaks the abstraction. PT-RED as a function would work
everywhere, without having to edit all uses of it as a step function in
a loop.
Ray