<endformationage>
BTW, the playground is fantastic for trying things out while learning!
_whitelogger has joined #ponylang
<codec_>
thanks for the info. I am just wondering how ergonomics it is in practice
<codec_>
for example, when accesing an element in an array, do I have to go through the whole try ... end thing, or can I have something like myArray(index).or_none()
<codec_>
which will give back a (T | None) -where T is the type of the array- depending of the correctness of the index
jemc has joined #ponylang
<endformationage>
codec_: Within the std library, and especially collections, such methods are partial and will require try blocks.
<endformationage>
You can assign to a variable as a result of a try expression for something similar to your or_none() (if I understand your intention)
<endformationage>
So yeah, in pratice Pony will be more verbose in dealing with partial calls, but quite clear in that such calls require error handling. Many prefering to have this clarity to succinctness.
<codec_>
thanks
<codec_>
but I think they are not exclusive
<endformationage>
What that says about the ergonomics of the code is up to preference I suppose.
<codec_>
I mean someArray(i)?.or_none() is quite a bit shorter than try someArray(i)? else None while still obivous
<codec_>
and that a simple example
<codec_>
Do you happen to know if this is something that address Pony in the future or it is done on purpose
<codec_>
Just to be clear, I think the current solution is by itself good, but may result in quite a lot of boilerplate
<endformationage>
Well, presumably there could be some sugar made available for some common/default cases such as with unions with None. Though I haven't seen it to be much an issue for myself.
<codec_>
So maybe it is not that much in practice
<endformationage>
I don't think so, and additional sugaring will come, but it is not a priority at this time AFAICT. Contributors to the compiler mya have more to say on this.
<codec_>
about the sugar, is it possible to write generic methods that would apply on "partial type" ?
<endformationage>
I am not clear on what is meant by partial type.
<codec_>
let's say I have a method that return a T?
<endformationage>
Sure, methods that are partial (may error) can be gereric.
<codec_>
can I write functions that can apply to them (T?) ?
<endformationage>
*generic
<codec_>
that was what I mean
<codec_>
:)
<codec_>
*n't
<codec_>
I mean can I treat T? has its own type ?
<codec_>
for example, If I want to reproduce the common type that Rust have (Option, Result), can I create generic methods to "emulate them"
<codec_>
such that it would allow me to write stuff like : myArray(i)?.or_none() or myArray(i)?with_default(3)
<codec_>
Earlier I tried but ended up using lambda which was less ergonomic that the try... else... solution
<endformationage>
I don't think so, because at the point that myArray(i)? errors, the or_none() and with_default(3) are not called, and the else clause of the try is invoked.
<endformationage>
Like I say, there may be room for some try block sugaring.
<codec_>
I see
<codec_>
thanks for taking time to answer my questions
<codec_>
I will wait to learn more about Pony before proposing an RFC or raising an issue though :)