nothrow by default

H. S. Teoh hsteoh at
Thu Jan 9 16:02:16 UTC 2020

On Thu, Jan 09, 2020 at 10:07:53AM -0500, Steven Schveighoffer via Digitalmars-d wrote:
> On 1/9/20 7:51 AM, Adam D. Ruppe wrote:
> > On Thursday, 9 January 2020 at 06:26:41 UTC, Walter Bright wrote:
> > > I expect that exceptions will soon become a legacy feature.
> > 
> > I've seen no evidence of that whatsoever. Exceptions, like GC, are a
> > proven winner in the real world with the vast majority of actually
> > existing industry code using them successfully.

+1.  This anti-exception sentiment I have a hard time understanding.

> I could see "nothrow by default" added making it an easier transition
> to Swift-like error handling (errors passed back on the stack, made to
> look like exceptions to user code).

Now *this* I can stand by.  Which makes me wonder if what's bothering
Walter about exceptions is not so much the concept of exceptions itself,
but their current implementation via stack unwinding, which requires
expensive setup of stack frames and what-not.

But it's possible to implement it differently, while still presenting an
exception-like interface to user code. You could pass errors back on the
stack, or even via a register dedicated for indicating error conditions,
and have the compiler automatically generate code for branching to an
error-handling part of the function (or have user code explicitly test
for it, if they so wish). This can be transparent to user code.


Who told you to swim in Crocodile Lake without life insurance??

More information about the Digitalmars-d mailing list