On 11/14/2010 10:37 PM, William Stein wrote:
On Sun, Nov 14, 2010 at 6:48 PM, Eviatar<eviatarb...@gmail.com>  wrote:
I thought Python was strongly typed. Definition from Wikipedia:

"Most generally, "strong typing" implies that the programming language
places severe restrictions on the intermixing that is permitted to
occur, preventing the compiling or running of source code which uses
data in what is considered to be an invalid way. For instance, an
integer division operation may not be used upon strings; a procedure
which operates upon linked lists may not be used upon numbers.
However, the nature and strength of these restrictions is highly
variable."

What do you mean by saying it isn't?
FYI, I've learned from experience that even using the phrases
"strongly typed" and "weakly typed" is a bad idea.
The problem is that there aren't any good accepted definitions of
them, and it is easy to find reputable sources that flatly disagree
with the definition at Wikipedia, unfortunately.

The original poster probably meant that Python is not "statically
typed".   (Another can of worms, but less of a problem.)

  - William
I agree with William that the "strongly typed" question is a
(well, I can't bring myself to use the "can of worms" analogy
given my prior analogy chastizing :-) )

To illustrate an example, it is possible to define:

  integer foo(integer x, integer y) {....}
  matrix  foo(integer x, integer y) {....}

and then write:

  integer a := foo(3,4)
  matrix  b := foo(3,4)

The question of which foo to call requires function dispatching
on the return type of the function. Few existing languages do this.

One place where this is useful is the construction of canonical forms.
The question of which result is simplest depends on the result you
expect. Consider that

    1     11
    - x + --
    7     13

is a polynomial with fractional coefficients and cannot be reduced. But

  13x + 77
  --------
     91

is a fraction of two polynomials with integer coefficients. They also
happen to represent the same value. Simplification of the value depends
on whether the desired result is a
  Polynomial(Fraction(Integer))
or a
  Fraction(Polynomial(Integer))

By specifying the target type you can define the simple form.

Tim Daly


--
To post to this group, send an email to sage-devel@googlegroups.com
To unsubscribe from this group, send an email to 
sage-devel+unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URL: http://www.sagemath.org

Reply via email to