oldk1331 wrote:
> 
> I discovered this when I was cleaning up the List Domain.
> 
> For
>    minIndex x == 1
> 
> This function compiles to:
> 
> (PUT '|LIST;minIndex;$I;10| '|SPADreplace| '(XLAM (|x|) 1))
> 
> (SDEFUN |LIST;minIndex;$I;10| ((|x| $) ($ |Integer|)) 1)
> 
> So, when inlining "minIndex(y)", that got replaced by 1.
> 
> But what if y is an expression, like "minIndex(f := empty())"?
> Then the definition of f got optimized away, later reference
> of f will cause error.
> 
> This bug happens in 'checkOrderN' in exprode.spad.
> 
> This 'XLAM' optimization mechanism is like C's macro,
> repeat its argument twice (or 0 times) may cause trouble.
> 
> Currently this affects minIndex of U8VEC/U16VEC/U32VEC,
> minColIndex/minRowIndex of U8MAT/U16MAT/U32MAT.
> 
> I wonder what a good solution would be.  To prevent them
> from being inlined or inline them more cleverly?

This should be easily fixable by change to inlining: assign
argument to new symbol and then pass the symbol to XLAM.
Actually the "minIndex(f := empty())" case does not need
a new symbol, during inlining Spad compiler should see 'f'
and pass it to XLAM.  So we need new symbol only in cases
when the toplevel operator in argument is _not_ an assignment.
This will probably force calls to various side-effect free
functions which are skipped now, but as long as we are not
_sure_ that a function is side-effect free we should do the
call.

-- 
                              Waldek Hebisch

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