Now, as I understood from documentation on wren.io, we don't know what we will get from the function - which type, class, object, or just our program will be shutting down because we have error in some place in function.
So, we need to have normal error handling features. And I have 2 thoughts about how we can implement it in Wren.
- Rust-like - Results with Errors and unwrap()
ourFunction(input) -> Result<String, Error> {
return Ok("") // or return Err("Message")
}
System.print(ourFunction("").unwrap())
match ourFunction("") {
Ok(v) -> System.print(v),
Err(e) -> System.print(e)
}
This way needs Enums to be implemented already.
- Java-like - Exceptions and try/catch
ourFunction(input) throws Exception -> String {
return "" // or throw Exception("")
}
try {
ourFunction("")
} catch(e) {
System.print(e)
}
So, I prefer Rust-like style, but I think, we need more thoughts from other developers for understand, what actually is really to implement in small Wren nature and which syntax is better to use in this cases.
Also, I think, good point is to have ability to mention type of value, which we return from function or get in function. Because it will rank up safety and, perspectively, performance of code, written in Wren.
Thanks for your work!
Now, as I understood from documentation on wren.io, we don't know what we will get from the function - which type, class, object, or just our program will be shutting down because we have error in some place in function.
So, we need to have normal error handling features. And I have 2 thoughts about how we can implement it in Wren.
This way needs Enums to be implemented already.
So, I prefer Rust-like style, but I think, we need more thoughts from other developers for understand, what actually is really to implement in small Wren nature and which syntax is better to use in this cases.
Also, I think, good point is to have ability to mention type of value, which we return from function or get in function. Because it will rank up safety and, perspectively, performance of code, written in Wren.
Thanks for your work!