The function 'first' in the List domain calls SPADfirst$Lisp which is
a rather clever Lisp macro

(defmacro |SPADfirst| (l)
  (let ((tem (gensym)))
    `(let ((,tem ,l)) (if ,tem (car ,tem) (first-error)))))

that seems to have no more measurable overhead than calling QCAR.
Perhaps someone with more Lisp experience than me can explain it?

I think probably that  (NULL (NULL x)) is optimized by Lisp (at least by SBCL).


On 9 October 2017 at 19:57, oldk1331 <[email protected]> wrote:
> On Mon, Oct 9, 2017 at 9:22 PM, Bill Page <[email protected]> wrote:
>> My benchmarking shows the Lisp macros QCAR and CONSP are no 'faster'
>> than calling 'first' and 'not empty?' from the List domain. Perhaps
>> this is due to some internal optimizations in SPAD and/or SBCL?  I
>> think it is best to avoid explicit Lisp dependencies if possible.  Is
>> your experience different?
>>
>> Bill Page.
>
> I didn't do a benchmarking, but I know that "first" does an extra empty check,
> and "not empty?" translates to (NULL (NULL x)) and can't be inlined.
>
> The compiler should not be able to optimize them away, there should
> be a performance difference in more complicated situation.
>

-- 
You received this message because you are subscribed to the Google Groups 
"FriCAS - computer algebra system" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/fricas-devel.
For more options, visit https://groups.google.com/d/optout.

Reply via email to