What does nothrow buy me?

Atila Neves atila.neves at gmail.com
Sat Nov 7 09:04:20 UTC 2020


On Wednesday, 28 October 2020 at 14:46:40 UTC, Steven 
Schveighoffer wrote:
> On 10/28/20 8:52 AM, Atila Neves wrote:
>> On Tuesday, 27 October 2020 at 18:21:23 UTC, H. S. Teoh wrote:
>>> On Tue, Oct 27, 2020 at 06:10:45PM +0000, Atila Neves via 
>>> Digitalmars-d wrote:
>>>> [...]
>>> [...]
>>>> [...]
>>>
>>> But how does it help in the case of throwing an Error from a 
>>> function registered with Python?  Arguably, that's something 
>>> you even *more* wouldn't want to do.
>>>
>>>
>>> T
>> 
>> Unfortunately, it doesn't. But errors are supposed to mean a 
>> non-recoverable problem anyway. I know it's not always like 
>> that in practice and that you don't want to crash someone's 
>> Excel sheet, but... making them nothrow makes me write a catch 
>> block, which makes me also catch errors.
>
> How does it make you write a catch block? If you only call 
> nothrow functions, then your function is nothrow. If you assert 
> in your nothrow function, it won't complain about catching.
>
> How does it make you write a catch block that catches Errors? 
> Catching Exception is sufficient to shut up the compiler.

Because the code I call from the nothrow function isn't nothrow 
itself. It's true that it won't force me to catch errors, but I 
tend to in wrapper code nearly automatically.

I realise now I didn't explain it well before.


More information about the Digitalmars-d mailing list