Paul Onions wrote:
> When I try to compile the following SPAD code:
> 
> --------------------------------------------------------------
> )abbrev package TEST TestPackage
> TestPackage(x) : Exports == Implementation where
>    x : Symbol
>    Exports == with
>      f : NonNegativeInteger -> UnivariatePolynomial(x, Fraction Integer)
>    Implementation == add
>      f(d) == x^d
> --------------------------------------------------------------
> 
> I get the following error message using Fricas 1.1.8:
> 
> --------------------------------------------------------------
> (1) -> )compile test.spad
>     Compiling FriCAS source code from file
>        /Users/pdo/Axiom/Test/test.spad using old system compiler.
>     TEST abbreviates package TestPackage
> ------------------------------------------------------------------------
>     initializing NRLIB TEST for TestPackage
>     compiling into NRLIB TEST
>     compiling exported f : NonNegativeInteger ->  
> UnivariatePolynomial(x,Fraction Integer)
> ****** comp fails at level 2 with expression: ******
> error in function f
> 
> (^ | << x >> | |d|)
> ****** level 2  ******
> $x:= x
> $m:= (UnivariatePolynomial x (Fraction (Integer)))
> $f:=
> ((((|d| # #) (|$Information| #) (|f| #) (|$DomainsInScope| # # #) ...)))
> 
>     >> Apparent user error:
>     Cannot coerce x
>        of mode (Symbol)
>        to mode (UnivariatePolynomial x (Fraction (Integer)))
> --------------------------------------------------------------
> 
> So am I doing something wrong here by trying to use a symbol as a  
> parameter to a package?

 
No.  The problem is that 'x' is a symbol and you want it treated
as polynomial.  In Spad (in contract to FriCAS command line)
there is no automatic conversion of symbols to polynomials.
Instead one normally uses 'monomial' function.  In your case:

)abbrev package TEST TestPackage
TestPackage(x) : Exports == Implementation where
   x : Symbol
   Exports == with
     f : NonNegativeInteger -> UnivariatePolynomial(x, Fraction Integer)
   Implementation == add
     f(d) == monomial(1, d)


-- 
                              Waldek Hebisch
[email protected] 

-- 
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 http://groups.google.com/group/fricas-devel?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to