On Thu, Mar 12, 2009 at 7:26 AM, Bill Page <bill.p...@newsynthesis.org> wrote:
>> +10. Otherwise every element has huge if-else lists in every
>> __add__, __sub__, __mul__, etc. corresponding to the fixed list
>> various possibilities that the programer original programmer thought
>> of at the time, and then those who've added to it.
>
> I do not understand this claim. As Ralf pointed out, there are good
> (i.e. "mathematical") reasons why it makes sense to multiply elements
> of GF(5) directly by integers. This has nothing to do with coercions
> or any other kind of type conversion per se. It makes sense to have
> this property of GF implemented locally. It would be inconvenient to
> have a symbol other than * to denote this operation. Because Python is
> dynamically typed, there is no alternative but to test some condition
> to determine what operation to perform. Using the coercion system to
> implement this kind of polymorphism moves some properties of GF into
> the coercion system instead of keeping it local.

It's still "implemented locally"... the coercion system doesn't know
anything about GF(5) until GF(5) is created and tells the coercion
system.  (Actually, it looks like GF(5) hasn't been transitioned to
the latest coercion API, so coercion doesn't know about GF(5) until
somebody actually tries to do something like GF(5)(3)*2; at which
point it will ask "GF(5), can Integers be coerced to you?")

The current system lets you also multiply elements of GF(5)['x']['y'],
MatrixSpace(GF(5)['x'], 4, 4), ..., by Integers; this would be much
harder to arrange if the information "GF(5) can be multiplied by an
Integer" was locked inside the source code of __mul__ for GF(5).

Carl

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

Reply via email to