On Tue, Aug 10, 2021 at 05:00:44PM +0000, Neven Sajko wrote:
> Hello,
>
> I notice that there is a function like this
> D: (%, Symbol, NonNegativeInteger) -> %
> in UnivariateTaylorSeries:
>
https://fricas.github.io/api/UnivariateTaylorSeries.html
>
> Why then does this Spad program not compile:
>
>
> )abbrev package XSMP XSomePack
> XSomePack(): Exports == Implementation where
>
> I ==> Integer
>
> Exports ==> with
>
> f: () -> I
>
> Implementation ==> add
>
> SYM ==> Symbol
> EXPR ==> Expression(I)
> TAY ==> UnivariateTaylorSeries(EXPR, 'x, 0$EXPR)
^^^^^^
The error message you see is weakness in Spad compiler. Namely
D is exported only if EXPR has PartialDifferentialRing(Symbol).
There is workaround for this problem. But type like above is
currently does not work. You can probaby get desired effect
by creating extra package. So, first, make a general package:
)abbrev package XSMP0 XSomePack0
XSomePack0(s : Symbol, cen : EXPR): Exports == Implementation where
and use s and cen instead of 'x and 0$EXPR in the body.
To work around first issue use fake conditional like
TAY ==> UnivariateTaylorSeries(EXPR, s, cen)
if TAY has PartialDifferentialRing(Symbol) then
diff(t: TAY, s: SYM, n: NonNegativeInteger): TAY ==
D(t, s, n)$TAY
Finally, use another package to provide fixed parameters:
)abbrev package XSMP XSomePack
XSomePack(): Exports == Implementation where
I ==> Integer
Exports ==> with
f: () -> I
Implementation ==> XSomePack0("x"::Symbol,
0$Expression(Integer))
Bottom line: expressions must occur as runtime actions. As
I wrote, some issues related to expressions in types require
coordinated change in many places. They also require fixing
some related problems (and some are already fixed).
--
Waldek Hebisch