On Fri, Feb 17, 2012 at 12:09:57AM -0800, hemmecke wrote:
> On Feb 14, 4:35 pm, Bill Page <[email protected]> wrote:
> > BTW, the type Any is like an "infinite" Union unfortunately it does
> > not export 'case'. So for the application that you illustrate perhaps
> > it would be better to be more explicit and write an actual Union. E.g.
> >
> > -----------------------------------------
> > ANY1 ==> AnyFunctions1
> > AnyLex ==> Union(Integer,String,Float)
> > SetAnyLexList ==>
> > Record( val : AnyLex, remList : List String)
>
> I strongly support Bill's suggestion of *not* using the Any type.
> Whenever it is possible, to be more explicit, one should use this
> information in the spad program.
>
> "Any" is more or less containing everything. It's nearly like
> forgetting about all types. IMHO, using Any is against the wish to do
> computer algebra with types that FriCAS focuses on. "Any" might be
> useful in rare cases and it still contains more information than an
> ordinary expression in a typeless CA system, but to me it feels like
> not using the full power of types, but rather program like in a
> typeless CAS.
>
The matter is the aim:
to implement in Spad only one function (dParse):
fast parsing from a list of strings to an arbitrary domain
potentially built by a certain fixed finite set of constructors:
Integer, Fraction, Polynomial, ResidueRing, Vector, Matrix
(may be, 3-4 more).
I knew that it is better to use Union.
But in the string interface the result of parsing from strings may occur
Integer, Fraction Integer, UP(x,Integer), UP(y, UP(x,Integer)),
UP(y, Fraction UP(x, Fraction Integer)),
...
-- an infinite union of types, even for these three domain constructors.
The book writes about dynamic domains. And I hoped for this from the very
start. But there was a doubt, it was clear that their usage is restricted.
And I thought, all right, let me try and see on practice what are these
restrictions.
Attempt II
----------
package ... DParse
DParse(CoefDom : CommutativeRing, NumDenomDom: IntegralDomain) with
...
dParse(lexemes: List String) : Union (Integer, CoefDom, NumDenomDom,
Fraction NumDenomDom,
UP CoefDom)
Now, it starts to parse the current lexs to a coefficient, and suppose
that lexs shows that this coefficient is a Fraction over some other
domain. dParse applies recursively, with package calling of the same
package (with substituting what domains for these three parameter domains?)
...
I never tried this, and doubt greatly.
Meanwhile, I am trying to see in example how concretely the attempt of
`Any' will stuck.
Regards,
------
Sergei
[email protected]
--
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.