A question came up to support float to mean f64. We can allow it, except that we support f64[5, 6] and f64[:,:] syntax for multidimensional arrays, and that does not work with the intrinsic type (float[:,:] or float[5,6] is an error in CPython).
Three approaches are available:
- Only support
float for scalar types, not arrays (so LPython would give an error message, as would CPython, for float[:,:])
- Create our own
float type in ltypes. For scalar values you can use it interchangeably with the builtin float, but for arrays you have to import it from ltypes, then float[:,:] would work
- Use built-in
float, allow for scalars, not allow float[:,:], but allow a more complicated syntax such a Array[float, 4, 5] and Array[float, :, :]. This might be a good idea, but we need to explore how to properly design this. Then f32[:,:] is just a syntactic sugar for Array[f32, :, :]. This longer syntax will become very verbose once you have a function that accepts 5 array arguments, each with multiple dimensions.
It seems we should encourage using f32 and f64, and then we avoid all these issues. We can allow float for only scalars, and for arrays LPython would say / recommend to use f64.
For more background, see:
A question came up to support
floatto meanf64. We can allow it, except that we supportf64[5, 6]andf64[:,:]syntax for multidimensional arrays, and that does not work with the intrinsic type (float[:,:]orfloat[5,6]is an error in CPython).Three approaches are available:
floatfor scalar types, not arrays (so LPython would give an error message, as would CPython, forfloat[:,:])floattype inltypes. For scalar values you can use it interchangeably with the builtinfloat, but for arrays you have to import it fromltypes, thenfloat[:,:]would workfloat, allow for scalars, not allowfloat[:,:], but allow a more complicated syntax such aArray[float, 4, 5]andArray[float, :, :]. This might be a good idea, but we need to explore how to properly design this. Thenf32[:,:]is just a syntactic sugar forArray[f32, :, :]. This longer syntax will become very verbose once you have a function that accepts 5 array arguments, each with multiple dimensions.It seems we should encourage using
f32andf64, and then we avoid all these issues. We can allowfloatfor only scalars, and for arrays LPython would say / recommend to usef64.For more background, see: