Python vs .Net

Brian Quinlan brian at sweetapp.com
Wed Jan 8 04:11:14 EST 2003


> Sorry - but my math is a bit rusty - wouldn't a matrix just be an
array
> of floats (or maybe complex numbers), that would seem to be a pretty
> straightforward definition and one that wouldn't impose an undo burden
> on using the routine.

A typical definition might be:

typedef float[4][4] matrix

But what if I want it to work with doubles? Or I do have a different
implementation of matrix that uses a single array of 16 floating point
types.


 
> > > Now regardless if we're talking about "+" or Add, I think that we
> can
> > > both agree on what to expect if both a & b are Integers or
Strings.
> > > What if one is an integer & one is a string, however.  What if the
> > > string has a numeric value?  What if we have an Integer and a
Float.
> >
> > It makes mathematical sense for integers and reals to be addable
> because
> > the set of integers is a subset of the set of reals.
> >
> > Strings and integers are quite unrelated.
> 
> Actually what I was trying to infer with this, and the reference to
the
> PEP later on, is that if you add 2 integers, I would expect an integer
> result. 

That's what you get.
> What kind of result would you get when adding an integer and a
> float?  Neither Python nor VB has any problems with that  & doesn't
> require a specific cast - I think that it's called 'promotion' or
> something like that in VB, where 2 compatible (but different type)
> arguments can be mixed and the result is in the form of the argument
> with the larger 'scale'(?)

If you have a hierarchy like this:

A
|___
B   C
|
D

If you add a C instance and a D instance, it would make sense that the
result is an A instance, because that is that the common base of the two
types.

Cheers,
Brian






More information about the Python-list mailing list