'unwrap envy' and exceptions
Paulo Pinto
pjmlp at progtools.org
Sun Sep 12 06:29:21 UTC 2021
On Sunday, 12 September 2021 at 01:50:37 UTC, H. S. Teoh wrote:
> On Sat, Sep 11, 2021 at 08:13:07PM +0000, Dukc via
> Digitalmars-d wrote:
>> On Friday, 10 September 2021 at 23:20:17 UTC, IGotD- wrote:
>> >
>> > Walter mentioned that exceptions are on the way out because
>> > they are expensive and inhibits the optimizer which are fair
>> > points. I interpreted this that Walter wants to move away
>> > from exceptions in D. Since then I haven't seen any
>> > proposal for any new error handling for D.
>>
>> Well the `@nodiscard` proposal, that is very likely to get
>> accepted, is sort-of one. It's basically about returning
>> traditional error values, but forcing the user to be explicit
>> if she really wants to summarily discard them.
>
> Whatever replaces exceptions better be darned good, otherwise I
> will be very unhappy. Explicit exception handling has its
> place, but in other cases it just uglifies code for no good
> reason. I don't really buy the performance argument: if your
> profiler pinpoints try/catch blocks as the bottleneck, it's not
> hard to refactor it to use error codes instead. Anything else
> is premature optimization. We should not uglify code just for
> some idealism that exceptions are somehow "bad".
>
>
> T
Yes, one thing that gets lost is the boilerplate required to
create error types, to the point that there are crates to work
around it.
https://users.rust-lang.org/t/how-to-reduce-boilerplate-when-wrapping-errors/39363/6
Beware what you wish for, the grass is not always greener on the
other side.
More information about the Digitalmars-d
mailing list