druntime function to query whether any exception is "in flight"
Meta
jared771 at gmail.com
Wed Oct 21 11:46:01 UTC 2020
On Wednesday, 21 October 2020 at 06:22:28 UTC, Petar Kirov
[ZombineDev] wrote:
> On Tuesday, 20 October 2020 at 17:45:19 UTC, Andrei
> Alexandrescu wrote:
>> On 10/20/20 11:23 AM, Adam D. Ruppe wrote:
>>> On Tuesday, 20 October 2020 at 15:16:33 UTC, Andrei
>>> Alexandrescu wrote:
>>>> One change please - can you have it return the current
>>>> exception as a Throwable (and null if no exception in
>>>> flight)?
>>>
>>>
>>> and prolly at least document that it shouldn't let the
>>> reference escape cuz otherwise it complicates memory freeing
>>> of the exception.
>>>
>>> basically it would be a borrowed reference. again at least
>>> just documented, not necessarily enforced, but people should
>>> be aware escaping it is UB.
>>
>> Nice.
>>
>> extern(C) scope(Throwable) _d_eh_getExceptionInFlight();
>
> onlineapp.d(1): Error: declaration expected, not `(`
>
> extern(C) scope Throwable _d_eh_getExceptionInFlight();
>
> onlineapp.d(1): Error: function
> `onlineapp._d_eh_getExceptionInFlight` functions cannot be
> `scope`
>
>
> Slightly off-topic: Unfortunately `scope` is a parameter
> storage class and not a type qualifier (which is probably the
> biggest point of contention regarding dip1000) so you can't
> express what you meant above.
>
> This has certain issues:
> * it makes expressing certain code patterns that should be safe
> impossible in @safe code (which are e.g. safe in Rust)
> * it makes some holes in @safe (both language and library) hard
> to fix. See e.g.: https://issues.dlang.org/show_bug.cgi?id=17764
> * doesn't help with concurrency safety issues, like these
> proposals:
> * https://forum.dlang.org/post/k831b6$1368$1@digitalmars.com
> *
> https://forum.dlang.org/post/kluaojijixhwigoujeip@forum.dlang.org
Related:
https://forum.dlang.org/thread/zayyoiupftrvbummxabk@forum.dlang.org
More information about the Digitalmars-d
mailing list