On Wed, Jan 27, 2021 at 09:54:42PM -0500, Tobias Neumann wrote:
> Hello Kurt, Waldek,
> thank you for those helpful links and the detailed example.
>
> I have extended the example type domain so that I can use 'approximate'
> (see below), which induces some further type constraints
> that do not seem to be satisfied by just Expression(Integer).
>
> While the code example below compiles fine, it seems that the retraction
> from AnyFunctions1 fails:
> >> Error detected within library code:
> Cannot retract value.
> The statements work fine with the FriCAS interpreter, so I assume that the
> interpreter performs some additional type conversion
> that I am missing here. What is the best way to debug something like this,
> given that the interpreter seems to take some additional steps that make it
> work.
> Could, in this case, 'retract' not report the type wrapped by 'Any' for
> debugging?
The problem here is that you gave wrong type as argument to
AnyFunctions1 (type wrapped by Any was OK). I saw the
problem by adding Lisp debugging printouts to
AnyFunctions1 and recompiling it.
In principle the problem should be catched at compile time,
but currently Spad compiler can not catch it. Difficulty is
that to do type checking we need types, but types have parameters
which need type checking and the whole thing is recursive
so we may learn that type parameters are OK only after we
had to use the type. Currently Spad compiler resolves this
taking type "on faith" and hoping that error will be caught
later. In this case type error survives to runtime.
Anyway, the problem is that you wrote:
UnivariateTaylorSeries(FE,ex,ex0)
where 'ex' is expression, while correct type is symbol.
At runtime (as Lisp value) 'x' as expression is quite
different than 'x' as symbol so AnyFunctions1
decided that you try to retract to wrong type and
signals error. Interpreter was smart enough to
notice that it needs symbol and converted 'x'
from expression to symbol.
There is another difficulty, literal 'x' does not
work as expected due to different representation
used in Spad compiler and in interpreter. Enough
indirection should work around this problem, for
example pass 3 arguments to 'my_taylor', including
symbol.
--
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/20210128221903.GA28859%40math.uni.wroc.pl.