[PYTHON MATRIX-SIG] casting and default types

P. Dubois dubois@kristen.llnl.gov
Mon, 6 Nov 1995 09:14:09 +0800


I agree with Konrad's view: the type of the matrix to be created from
a list should be the least type conforming to all the components,
and the same should go for the result of an expression.

One could have the Matrix_? operators which strictly required the correct
kind of list as an argument, and just plain Matrix(list) would be the
creation routine which was "clever" at figuring this out.

In Basis, [1,2,3] is an integer array, [1,2,3.] is a real array.

Combined with the expression rule, this works well. I think no coercion
is probably workable but less desireable.

Related to this is what such "coercion" means for characters. If you
have a list [a,b,c] where a,b,c are all strings, Basis interprets the
"type" of the resulting matrix to be "strings of length max(len(a),len(b),
len(c)), and the component strings are copied into the new structure with
right blank fill to this new length.

(I keep mentioning Basis simply as a way of letting you all know what one way
is that users found acceptable; this is a set of semantics that has 10 years
of intensive user testing. When there is something the users didn't like
about it, I'll tell you that too. In this area, there are no complaints
whatsoever.)







=================
MATRIX-SIG  - SIG on Matrix Math for Python

send messages to: matrix-sig@python.org
administrivia to: matrix-sig-request@python.org
=================