Ralf Hemmecke <[EMAIL PROTECTED]> writes:

> The only difference between Sage and Aldor/panAxiom is that Sage checks 
> whether the Object can be coerced to SomeType at runtime whereas Aldor 
> and SPAD allow to check at compile time.

I don't think this is the full story.  As far as I can see, it is the
responsibility of the programmer to do the dispatch, i.e., 

if arg is string then do this
if arg is number then do that

etc. (please correct me if I'm wrong!!!)

If this is not properly done, the user will get *some* error message, not
necessarily informative.

In FriCAS, the message is standardized:

(5) -> 1.5::INT
 
   Cannot convert from type Float to Integer for value
   1.5

(5) -> "1213" :: Float
 
   Cannot convert from type String to Float for value
   "1213"

simply because there is no suitable function coerce: String -> Float.

(I'm cheating I tiny bit here, but I believe I got the philosophy right)

If one get's the arguments of a function wrong, the message is also
standardized - possibly it could be better, but anyway:

(7) -> D(x^2, x, x)
   There are 3 exposed and 0 unexposed library operations named D 
      having 3 argument(s) but none was determined to be applicable. 
      Use HyperDoc Browse, or issue
                                )display op D
      to learn more about the available operations. Perhaps 
      package-calling the operation or using coercions on the arguments
      will allow you to apply the operation.
 
   Cannot find a definition or applicable library operation named D 
      with argument type(s) 
                             Polynomial(Integer)
                                 Variable(x)
                                 Variable(x)
      
      Perhaps you should use "@" to indicate the required return type, 
      or "$" to specify which version of the function you need.

(Because in FriCAS, the syntax for differentiation is D(fun, var, how-often),
but obviously, one might believe that it is D(fun, var1, var2,...))

I think that Sage / Python could be improved here (not that I want to do it - I
hope you accept this "criticism" as constructive).  For example:

sage: parametric_plot(1, x, (0,4))
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)

/home/rubey/<ipython console> in <module>()

/opt/local/sage-3.1.2/local/lib/python2.5/site-packages/sage/plot/plot.py in
parametric_plot(funcs, tmin, tmax, **kwargs)
   3786
   3787     """
-> 3788     if len(funcs) == 3:
   3789         raise ValueError, "use parametric_plot3d for parametric plots
in 3d dimensions."
   3790     elif len(funcs) != 2:

TypeError: object of type 'sage.rings.integer.Integer' has no len()

But what I'd like to see: "x" is not a range.

Similarly:

sage: contour_plot(x^2==0, (0,4), (0,4))
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)

/home/rubey/<ipython console> in <module>()

/opt/local/sage-3.1.2/local/lib/python2.5/site-packages/sage/plot/plot.py in
contour_plot(f, xrange, yrange, **kwds)
   2917     xy_data_array = [[g(x, y) for x in \
   2918                       sage.misc.misc.xsrange(xrange[0], xrange[1],
xstep)]
-> 2919                       for y in sage.misc.misc.xsrange(yrange[0],
yrange[1], ystep)]
   2920
   2921     g = Graphics(xmin=float(xrange[0]), xmax=float(xrange[1]),
ymin=float(yrange[0]), ymax=float(yrange[1]))

/opt/local/sage-3.1.2/local/lib/python2.5/site-packages/sage/calculus/equations.py
in __call__(self, *args, **argv)
    211         from sage.calculus.all import SR
    212         m = matrix(SR, 1, 2, [self._left, self._right])
--> 213         left,right = m(*args, **argv)[0]
    214         return self._op(left, right)
    215

/home/rubey/matrix_symbolic_dense.pyx in
sage.matrix.matrix_symbolic_dense.Matrix_symbolic_dense.__call__
(sage/matrix/matrix_symbolic_dense.c:5608)()

ValueError: the number of arguments must be less than or equal to 1

But what I'd like to see: first argument has to be a function.

The dynamic typing philosophy gives more flexibility, but also more
responsibility, it seems.

Martin


--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to sage-devel@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/sage-devel
URLs: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---

Reply via email to