Hi, 

I seem to need convert() a lot, and especially for arrays this is somewhat 
of a nuisance.  E.g., 

convert(Float32, rand(2,3))

does not work out of the box.  Luckily, for the numeric types there are the 
functions float64(), float32() etc that can operate on arrays.  This is all 
good, but for parameterized functions/types that need to convert to type T 
<: Real it seems a bit of a hassle to find the accompanying convenience 
function for type T. 

So I wonder, would it be possible to include in Base a function

convert(T::Type) = <the convenience function for T>

so that you could say

t = Float32
convert(t)(randn(2,3))

My current solution for such conversion is

map(x->convert(t,x), randn(2,3))

but that doesn't seem great. 

An alternative would be to include in Base a number of declarations like

convert(Float32, x) = float32(x)

What is your view on this?

---david

Reply via email to