I want off Mr. Golang's Wild Ride

Ola Fosheim Grøstad ola.fosheim.grostad at gmail.com
Mon Mar 2 13:56:19 UTC 2020


On Sunday, 1 March 2020 at 15:25:48 UTC, Ali Çehreli wrote:
> I don't even know what ad-hoc Go exceptions are. :)

panic/recover! :-)

> [3] One problem I learned last year was the fact that even 
> though there can be one exception in flight, there can be 
> unlimited number of exception objects that are in caught but 
> not yet destroyed state:
>
> try (foo()) {
>   // ...
> } catch (const Exception & e) {
>   bar();
> }
>
> bar() may throw and handle another exception, which would 
> normally be fine. However, note that 'e' of this block is still 
> alive until bar() returns, which means there can be unlimited 
> number of objects, which does not fit with "allocate all your 
> memory up front" philosophy of some embedded systems. This was 
> news to me until the end of last year.

I think this to a large extent is a problem with separate 
compilation and standard C++ development suites. For embedded 
you'd rather have statically determined stack-depth and and one 
should be able to do the same statically for exceptions, but as 
long as exceptions are deemed unsuitable for embedded then there 
is no market for such static checks so.... egg and chicken... 
:-/. Not an inherent trait of exceptions, but... programming 
culture and common patterns makes change difficult. I guess.




More information about the Digitalmars-d mailing list