From: Gabriel Dos Reis <gdr@cs...> - 2012-03-12 19:06:59
"Serge D. Mechveliani" <mechvel@...> writes:
| I need to build (in Spad) an element x : (D : EuclideanDomain)
| into SExpression.
I suspect the real issue is why you want SExpression as target,
therefore forgoing the typing relation? It is agreable to you to
maintain the type information even when you use a uniform syntax
representation like SExpression? If yes, why don't you use Any?
| I do not mind to set it there, for example, via OutputForm.
| So, I try
| )abbrev package FOO Foo
| Foo(D : EuclideanDomain) : with
| f : D -> SExpression
| f x ==
| xOF := coerce(x) :: OutputForm
| xI := convert(xOF) $InputForm
| xStr := unparse(xI) :: String
| convert(xStr :: Symbol) $SExpression
| I have spent 1 hour to find this conversion which satisfies the compiler.
| Instead of writing
| x :: OutputForm :: String :: SExpression,
| one needs to guess of all these clever coerce, convert, unparse,
| and also of introducing InputForm, where this InputForm seems to have
| no relevance to the subject.
| 1. Is there possible a simpler code?
| 2. If it is not, can the compiler be improved in this point?
| I suspect that all such questions about improving the compiler need to be
| consdered in the frame of Aldor, and one could write things in Aldor,
| with using the FriCAS library.
| a) I do not know, of whether Aldor is currently workable in this mode,
| b) it seems, there are some problems with openness and license.
| 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 fricas-devel@...
| To unsubscribe from this group, send email to fricas-devel+unsubscribe@...
| For more options, visit this group at http://groups.google.com/group/fricas-devel?hl=en.
From: Gabriel Dos Reis <gdr@cs...> - 2012-03-12 20:14:06
Ralf Hemmecke <ralf@...> writes:
| On 03/12/2012 05:51 PM, Serge D. Mechveliani wrote:
| > I need to build (in Spad) an element x : (D : EuclideanDomain)
| > into SExpression.
| The first question I would have: Why?
| SExpression is losing all type information, as a FriCAS programmer,
| one would think twice about the need of such a function.
| I D is a EuclideanDomain, then there are no exported functions to turn
| an element of D into SExpression. If you don't additionally require
| from D that it exports a function foo: % -> SExpression, the only
| thing you can do, is via (type unsafe) tricks.
OpenAxiom allows users to *safely* unpack values of the existential type Any:
case expr is
x: exist(D: EuclideanDomain) . D => something with x
otherwise => do something else