1. Extracting agrument domain from under a constructor
------------------------------------------------------
Is it possible in Spad to extract an argument domain (type) from a
constructed domain?
In general: No.
For example,
F : Field := ...
If you know that the type of F is Field, you don't know that it was
constructed by Fraction.
And it is known that F = Fraction D for some D : IntegralDomain,
How do you happen to know this information in a program? I would bet, if
you know that it's a fraction, you also know D.
Your use case is not quite clear. I guess it has something to do with
parsing and coercing strings to FriCAS expressions, but please be more
precise.
But D is not given in the scope.
Why do you need D at all?
Can D be extracted from F by some operations,
so that, for example, the operations `1 :: D', `(f^2) $UP(x, D)'
become possible?
Extracting D would be possible by something like this:
Foo(D: IntegralDomain): with
...
argDomain: () -> IntegralDomain
== add
...
argDomain(): IntegralDomain == D
BUT, now comes the problem. If you have
D ==> Integer
F ==> Foo(D)
E ==> argDomain(F)
how can the compiler check that for
d: D := 1
e: E := 1
it can add d and e? The compiler would have to verify that there is a
function +: (D, E) -> ??? or check that D is the same as E. But checking
that would involve evaluating the *function* argDomain at compile time.
The compiler doesn't do this.
Of course, since you know, you can simply pretend, but that is
inherently type unsafe.
Generally, I don't find the extraction of argument domains very
attractive. IMHO, it would be wiser to remember the construction of the
domain in question and also remember its arguments so that they can be
used in other places.
Ralf
--
You received this message because you are subscribed to the Google Groups "FriCAS -
computer algebra system" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/fricas-devel?hl=en.