[Aldor-l] coercion problem
Martin Rubey
martin.rubey at univie.ac.at
Fri Nov 14 03:00:47 EST 2008
I'd like to report on a curious problem I have with SPAD/Aldor, which Python
does not seem to have.
In Axiom, we currently have the (mostly unused) Categories
CoercibleTo S, RetractableTo S and ConvertibleTo S that provide
coerce: % -> S, coerce: S -> % and retract: % -> S
respectively. One can then ask
(4) -> SquareMatrix(2, INT) has CoercibleTo Matrix INT
(4) true
Type: Boolean
Very unfortunately, currently in almost all cases the query "has CoercibleTo
Something" will return false, because the coerce function is not inherited by
the category.
Now, I would like that for domains of the same category, say
UnivariatePolynomialCategory, that differ only in the representation of their
elements, say sparse or dense, we would have
A has CoercibleTo B and B has CoercibleTo A
Eg., we could have a package
UPOLYCoerce(A: UPOLYC, B: UPOLYC)
that implements coerce: A -> B generically, using only operations from the
category UPOLYC.
But it seems that we cannot teach Aldor/SPAD, that for all domains A and B of
UPOLYC we have
A has CoercibleTo B and B has CoercibleTo A
In Sage/python, this seems possible, although I'm not quite sure about it.
There, people implement a general coerce method in UPOLYC, that checks whether
it's argument is of the right type. I admit, I do not know whether we can then
ask for two given types whether we can do the coercion. Sorry for being very
vague here, I simple do not know the details.
Martin
More information about the Aldor-l
mailing list