4 ms·
I really think that's an useful tutorial for all languages with exceptions ( that's an exceptional event ) and normal control flow ( application error, validati
by enricosada 10y ago
I really think that's an useful tutorial for all languages with exceptions ( that's an exceptional event ) and normal control flow ( application error, validation, retry ).
Like that code become really simple, but more expressive than returning an int error code each function. A function can return an error with messages or message+data or message+retrycount etc.
With F# (can be done in other languages obv) it's really easy to have different success/failure return types ( amazing type inference ) without writing too much code or having issues with maintenance ( the compiler does his job for us ).
Like that, it's easy to create simple pure function, easier to test and reason about.
- logicallee 10y ago>for all languages with exceptions ( that's an exceptional event ) Unless, like me, you expect the unexpected. // if we're still here, guess it worked! return retval; }
- novaleaf 10y agoFYI, this "railway" approach is basically the way Promises work.