Feedback from the Gripes and Wishes Campaign

Basile B. b2.temp at gmx.com
Fri May 26 14:15:48 UTC 2023


On Friday, 26 May 2023 at 12:42:41 UTC, FeepingCreature wrote:
> On Thursday, 25 May 2023 at 15:36:38 UTC, Commander Zot wrote:
>> On Friday, 19 May 2023 at 15:58:25 UTC, ryuukk_ wrote:
>>>
>>> For example:
>>>
>>> - **exception handing**: why use EH when you can have your 
>>> function return 2 values (error and result)
>>
>> oh god no. it leads to horrible code. just take a look at go.
>
> Go is an unusually atrocious implementation. In a not terrible 
> language, it just looks like `foo()?.bar()?.baz`.

The problem of the optional access is understanding the side 
effects. It looks simple to use, and it really is, at first 
glance. The problem is that things are not necesarilly made to be 
shortcut (btw are they really shortcut ?).

So...

1. with calls the problem is that actually it looks like very 
safe while it should be only used by the people who know very 
well the API... like maybe the thing should be called and having 
null as parameter is actually a meaningfull error (after all)
2. optional accesses chains are not as well optimisable as AndAnd 
chains (which them are really shortcut)

it's a matter of knowing where to use them, like in cold paths 
it's ok.
But well maybe it's just my implementation that's bad.

Slightly off-topic but the question mark uses I really like, as 
said a few days ago, are `?=` and the elvis (`??` or `?:`, etc. 
there might exist other syntaxes)


More information about the Digitalmars-d mailing list