On Mon, Mar 08, 2021 at 05:21:01PM +0100, Ralf Hemmecke wrote:
> Just for the record.
> 
> In my code I had something like this where
> LZ ==> List Integer
> 
>     qetaGrades(x: %): LZ ==
>         zero? x => [-1 for k in 1..ncusps]
>         [qetaGrade(x, k pretend PositiveInteger) for k in 1..ncusps]
> 
> That compiles fine. Now I ran into a case where "zero? x" was true.
> Instead of getting a list of -1 entries, I got:
> 
> Function:  -? : % -> % is missing from domain: NonNegativeInteger
>    Internal Error
>    The function - with signature $$ is missing from domain
>       NonNegativeInteger
> 
> It is easy to resolve via "-1$Integer", but it is sad that the compiler
> accepts something and then produces code that throws an error, is not good.
> 
> I wonder by what mechanism the SPAD compiler finds a function "-" with
> signature NonNegativeInteger -> Integer.

You posted incomplete code.  When I added declarations needed to
compile it Spad compiler treated -1 as an Integer constant (as
it should) and there were no call to '-'.

If you want details you need to provide actual compilable testcase.
If you want abstract divagations, note that '-' is defined in
categories on condition that NonNegativeInteger has AbelianGroup.
Compiler should be smart enough to note that this condition
is false, but sometimes passes inconclusive cases to be
caught at runtime (if condition is actually satisfied, then
code works fine).
-- 
                              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 view this discussion on the web visit 
https://groups.google.com/d/msgid/fricas-devel/20210308175833.GC1217%40math.uni.wroc.pl.

Reply via email to