> Ralf Hemmecke wrote:
> ...
>> >> 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
On Thu, Jun 11, 2009 at 3:25 PM, Waldek Hebisch wrote:
> ...
> 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.
Since
(1) -> Any has BasicType
(1) true
Type: Boolean
(2) -> )sh BasicType
BasicType is a category constructor
Abbreviation for BasicType is BASTYPE
This constructor is exposed in this frame.
------------------------------- Operations --------------------------------
?=? : (%,%) -> Boolean ?~=? : (%,%) -> Boolean
(2) ->
I do not think one should expect an error message.
>
> 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])
>
As Martin said some emails ago there is no good reason for Any to have
SetCategory.
On Wed, Jun 10, 2009 at 1:03 PM, Martin Rubey wrote:
> ...
> Object(C: Category): with
> any : (C, None) -> %
> [...]
> dom : % -> C
>
>
> Then Johannes could say
>
> aa := "A"::Any
> bb := "A"::Any
>
> test(aa::dom(aa) = bb::dom(aa))
>
> apart from that I think that Any should not export SetCategory.
>
Any does not export a comparison, but there is not a problem if we use
inequalities. E.g.
(1) -> a:Any:="x"
(1) "x"
Type: String
(2) -> b:Any:="x"
(2) "x"
Type: String
(3) -> (a<=b and a>=b)
(3) true
Type: Boolean
(4) ->
Apparently the reason that the compound inequality works is because
the AnyFunctions1 package exposes a 'retract' function and the
interpreter is smart enough to use it as part of it's function
selection algorithms.
So if we simply remove the definition of = from Any as in the patch below:
wsp...@debian:~$ diff -au any.spad.orig any.spad
--- any.spad.orig 2009-06-11 16:34:54.000000000 -0400
+++ any.spad 2009-06-11 16:47:20.000000000 -0400
@@ -16,7 +16,7 @@
++ losing any of the original information. Any object can be converted
++ to one of \spadtype{Any}.
-Any(): SetCategory with
+Any(): CoercibleTo(OutputForm) with
any : (SExpression, None) -> %
++ any(type,object) is a technical function for creating
++ an object of \spadtype{Any}. Arugment \spad{type} is a
\spadgloss{LISP} form
@@ -49,7 +49,6 @@
obj x == x.ob
dom x == x.dm
domainOf x == x.dm pretend OutputForm
- x = y == (x.dm = y.dm) and EQ(x.ob, y.ob)$Lisp
objectOf(x : %) : OutputForm ==
spad2BootCoerce(x.ob, x.dm,
--
then we can get the expected result from the interpreter:
(1) -> )co any.spad
Compiling FriCAS source code from file /home/wspage/any.spad using
old system compiler.
ANY abbreviates domain Any
(1) -> a:Any:="x"
(1) "x"
Type: String
(2) -> b:Any:="x"
(2) "x"
Type: String
(3) -> c:Any:="y"
(3) "y"
Type: String
(4) -> (a=b)@Boolean
(4) true
Type: Boolean
(5) -> (a=c)@Boolean
(5) false
Type: Boolean
There is a minor difficulty however. The domain Equation(Any) no
longer displays properly.
(6) -> a=b
Loading /home/wspage/ANY.NRLIB/ANY for domain Any
LISP output:
(((String) . x) (String) . x)
Type: Equation(Any)
This is simply because Equation has
coerce : % -> OutputForm if S has SETCAT
The condition here really should be looking only for CoercibleTo(OutputForm).
Regards,
Bill Page.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---