Open tonyfettes opened 1 month ago
@tonyfettes Maybe the functions of all core
module have to add the error
feature. But i wish you do not use error feature in you code. Because this feature influences all related code if you use it. Just like now scene you face.
let value : FixedArray[Tensor] = FixedArray::makei(xs.length(), fn(i) {
Tensor::from_json!(xs[i], @json.add_index(path, i))
})
Tensor::stack(value)
Note you work around this using for .. in
, I am hestitant to add such API since eventually want our map
to propagate callbacks with Error something like this:
map[A](self : Array[A], f : (A) ->B!_) -> Array[B]!_ // when call back has error, result has error
It's often the case when I want to construct an
Array[T]
orFixedArray[T]
from a function that can raise error. For example, I want to construct aTensor
from aJson
value:For now it is not possible to achieve this, since
FixedArray::makei
require the callback to be error-free.