Ralf Hemmecke wrote:
>
> On 06/11/2009 05:31 PM, Waldek Hebisch wrote:
> > Ralf Hemmecke wrote:
> >> However, as Waldek already said. The above definition for = is dangerous.
> >>
> >> I would rather like to have something like
> >>
> >> x = y ==
> >> dx := dom x
> >> dy := dom y
> >> dx ~= dy => false
> >> Dx := EVAL(dx)$Lisp
> >> if Dx has BasicType
> >> then (obj x) pretend Dx = (obj y) pretend Dx
> >> else false
> >>
> >
> > Actually, this version will silently produce wrong resuls.
>
> Does that mean that even with the fix r624 that code above with
>
> if Dx has BasicType
>
> would not work as expected?
>
You return false if type has no equality -- this has good chance
being wrong. Signaling error is probably the best. I thought
that without check comparison may crash, so I considered adding
explicit call to error. However, after looking at generated
code I see that there is check before call, so no need to code
extra check.
Two more remarks:
1) You need to declare Dx as type, otherwise compile will fail
(even in r624).
2) Actually, other problem I mentioned is more serious: EVAL
does not work for domains with nontrivial non-type parameters,
like SAE(FRAC INT, UP(x, FRAC INT), x^2-3). One then needs
to replace EVAL by more complicated function, something like
evalType(t) ==
op := opOf t
args := rest t
cs := rest GETDATABASE(op, 'COSIG)
nargs := [if c then a else ["QUOTE", a] for a in args for c in cs]
EVAL([op, :nargs])
--
Waldek Hebisch
[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
-~----------~----~----~----~------~----~------~--~---