[OT] Is there a real alternative to exceptions ?
Mensikovk
mensikovk817 at gmail.com
Mon Feb 3 15:02:39 UTC 2025
On Thursday, 16 January 2025 at 19:02:05 UTC, Basile B. wrote:
> I have the feeling that things like
>
> ```
> a.map!(mapperFun).reduce!(reducerFun).array;
> ```
>
> is only possible thanks to an exception system. A similar
> expressivity looks impossible for example with the idom of
> result tuple `(error_code, actuallResult)`.
>
> that problem is currently something rather serious, in the
> sense that, let's say you want to make a standard library, you
> really need to have a well defined way of handling errors.
>
> I'll be interested to read your thoughts on that topic.
Koka programming language has cool effect system. Its powerful as
monads, but pretty simple.
In D there is already the beginning of this system: pure, @safe,
@nogc, nothrow. But in koka they are polymorphic. Also, these
koka effects allow you to implicitly configure modules with the
necessary callbacks. These effects also allow you to implement
async/await, exceptions, generators, and some programs with
complex flow control at the program level without having to
change the compiler.
https://koka-lang.github.io/koka/doc/book.html#sec-effect-types .
If you add them to D, then you can transfer many D features to
the runtime library altogether.
More information about the Digitalmars-d
mailing list