On 10 October 2017 at 03:03, oldk1331 <[email protected]> wrote:
> On Tue, Oct 10, 2017 at 10:30 AM, Bill Page <[email protected]> 
> wrote:
>> 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?
>
> Well, it's the difference between (if x (car x)) and (car x).
>

So calling (if x ... ) must have very low cost.  If you don't like the
error message produced by SPADfirst it might be a good idea to define
an analogous macro for use in 'Maybe' and that way avoid the need for
the unsafe 'unwrap!' operator.

>> I think probably that  (NULL (NULL x)) is optimized by Lisp
>> (at least by SBCL).
>
> Yes, but at Spad level, (CONSP X) is inlined, while
> (NULL (NULL x)) is not inlined, which involves a ELT lookup
> and a function call.
>

OK. I must not have measured what I thought I had measured.  Why is
(NULL (NULL x)) not inlined? It looks like it should be easy.

> BTW, your benchmarking might be misleading, because when
> you modify a previously inlined function to not-inlined, then the
> previous inline information is still in the system.  This should be
> considered a small annoying bug. AKA if you modified a inline
> domain, you should compile FriCAS again to do benchmark.
>

Thank you for the tip.  That is confusing.

-- 
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