>>> I'll second this. Are there *any* computer algebra systems (or
>>> programming languages for that matter) out there such that 4/2 != 2 !=
>>> 2.0? Code would simply be too hard to write.
>>
>> Ada, I guess. It should give error if you try to compare integer with float.
> 
> Ah, no wonder it's so widely used :).

Right. ;-)

In FriCAS you get

  (1=1.0)@Boolean

if you type that in a session, but ...

(200) -> )compile foo.spad
   Compiling FriCAS source code from file
      /home/hemmecke/foo.spad using old
      system compiler.
   FOO abbreviates package Foo
------------------------------------------------------------------------
   initializing NRLIB FOO for Foo
   compiling into NRLIB FOO
   compiling exported foo : () -> Boolean
****** comp fails at level 3 with expression: ******
error in function foo

(= (|Sel| (|Integer|) 1) (|Sel| (|Float|) 1))
****** level 3  ******
$x:= (Sel (Float) (One))
$m:= (Integer)
$f:=
((((|$Information| #) (|foo| #) (|$DomainsInScope| # # #) ($ # #) ...)))

   >> Apparent user error:
   Cannot coerce (call (XLAM ignore 1))
      of mode (Integer)
      to mode (Float)

for the source code:

)abbrev package FOO Foo
Foo: with
    foo: () -> Boolean
  == add
    foo(): Boolean == (1$Integer = 1$Float)

In other words. For the compilation, there will be no automatic
coercion, but in a interactive session, FriCAS will try to find
respective types so that the function (here it is

   =: (%, %)-> %

) is available. I.e. in the above case it finds

  coerce: Integer -> Float

and thus uses

   =: (Float, Float)-> Float

in a session.

Maybe that is not what you want or even can do in Sage, but I find this
programming vs. interactive session distinction rather good. I don't
like if my program suddenly behaves differently only because someone has
slightly changed the coercion system.

As a programmer I would like to have control on whether I consider the
integer 1 equal to the 2 by 2 unit matrix.

We do the same in mathematics. Rational numbers are pair of integers
modulo ... so how can they be equal to an integer? Yes, we have an
embedding. The question is simply whether one wants a system that hides
that embedding (coercion) or a sytem that makes that coercion explicit.
I think FriCAS makes a good compromise with this.

Just my 2 cents.

Ralf

-- 
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-devel+unsubscr...@googlegroups.com.
To post to this group, send email to sage-devel@googlegroups.com.
Visit this group at http://groups.google.com/group/sage-devel.
For more options, visit https://groups.google.com/d/optout.

Reply via email to