www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - betterC and exceptions

reply Ola Fosheim =?UTF-8?B?R3LDuHN0YWQ=?= <ola.fosheim.grostad gmail.com> writes:
What does it take to get some kind of exceptions in betterC?

I would think that it would be sufficient to either limit the 
size of an exception and provide a fixed size buffer in 
thread-local-storage (256 bytes).

Yes, that means giving up throwing "strings" and retaining old 
exceptions, but I think that is acceptable for system level 
programming.
Nov 12 2021
parent reply Imperatorn <johan_forsberg_86 hotmail.com> writes:
On Friday, 12 November 2021 at 08:44:08 UTC, Ola Fosheim Grøstad 
wrote:
 What does it take to get some kind of exceptions in betterC?

 I would think that it would be sufficient to either limit the 
 size of an exception and provide a fixed size buffer in 
 thread-local-storage (256 bytes).

 Yes, that means giving up throwing "strings" and retaining old 
 exceptions, but I think that is acceptable for system level 
 programming.
I think LWDR also tries to solve this. Maybe a similar approach could be used.
Nov 12 2021
next sibling parent reply Ola Fosheim =?UTF-8?B?R3LDuHN0YWQ=?= <ola.fosheim.grostad gmail.com> writes:
On Friday, 12 November 2021 at 09:04:48 UTC, Imperatorn wrote:
 I think LWDR also tries to solve this.
 Maybe a similar approach could be used.
This? https://github.com/hmmdyl/LWDR Hm, looks like they add a lot of stuff, but some of it seems to be opt-in. Their plan says they have a working implementation for GDC, but not LDC: https://github.com/hmmdyl/SAoC2021/blob/main/plan.md Ok, let's see what they come up with. The ideal would be to reuse whatever C++ does.
Nov 12 2021
parent reply Elronnd <elronnd elronnd.net> writes:
On Friday, 12 November 2021 at 09:13:22 UTC, Ola Fosheim Grøstad 
wrote:
 Ok, let's see what they come up with. The ideal would be to 
 reuse whatever C++ does.
I believe C++ uses reference counting.
Nov 12 2021
parent Paulo Pinto <pjmlp progtools.org> writes:
On Saturday, 13 November 2021 at 01:06:00 UTC, Elronnd wrote:
 On Friday, 12 November 2021 at 09:13:22 UTC, Ola Fosheim 
 Grøstad wrote:
 Ok, let's see what they come up with. The ideal would be to 
 reuse whatever C++ does.
I believe C++ uses reference counting.
Each compiler does its own way, and on Visual C++'s case it takes advantage that Windows supports exceptions at the OS level.
Nov 12 2021
prev sibling parent reply Ola Fosheim =?UTF-8?B?R3LDuHN0YWQ=?= <ola.fosheim.grostad gmail.com> writes:
On Friday, 12 November 2021 at 09:04:48 UTC, Imperatorn wrote:
 I think LWDR also tries to solve this.
 Maybe a similar approach could be used.
This? https://github.com/hmmdyl/LWDR Hm, looks like they add a lot of stuff, but some of it seems to be opt-in. Their plan says they have a working implementation for GDC, but not LDC: https://github.com/hmmdyl/SAoC2021/blob/main/plan.md Ok, let's see what they come up with. The ideal would be to reuse whatever C++ does.
Nov 12 2021
parent reply russhy <russhy gmail.com> writes:
betterC doesn't need exception

why do you want that? use error codes

if that's not enough, let's think about something better than 
exception
Nov 12 2021
parent Ola Fosheim =?UTF-8?B?R3LDuHN0YWQ=?= <ola.fosheim.grostad gmail.com> writes:
On Friday, 12 November 2021 at 21:25:06 UTC, russhy wrote:
 betterC doesn't need exception

 why do you want that? use error codes

 if that's not enough, let's think about something better than 
 exception
You mean error codes with throw/catch syntax?
Nov 12 2021