<div dir="ltr"><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, 28 Aug 2024 at 23:52, Richard (Rikki) Andrew Cattermole via Digitalmars-d <<a href="mailto:digitalmars-d@puremagic.com">digitalmars-d@puremagic.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On 29/08/2024 1:41 AM, Manu wrote:<br>
>Â Â Â > And if someone does a binary-back-door... who cares? That's<br>
>Â Â Â called a BUG.<br>
>Â Â Â > They're playing with fire already! C doesn't have any such type<br>
>Â Â Â safety, and they<br>
>Â Â Â > shouldn't expect it to.<br>
>Â Â Â > They know what they did; they did it intentionally, surely knew<br>
>Â Â Â what the risk<br>
>Â Â Â > factors were, and they are naturally expected to not write such<br>
>Â Â Â bugs into their<br>
>Â Â Â > program.<br>
> <br>
>Â Â Â The author of the C code likely has no idea that the caller from D<br>
>Â Â Â exists let<br>
>Â Â Â alone that it would require that the C code not call any D functions.<br>
> <br>
> <br>
> The author of the library expects you to use the library via the API <br>
> they provide... their API is C code; if C code is nothrow @nogc, then <br>
> the callback you provide is necessarily nothrow and @nogc also.<br>
> I really can't see the fuss here...<br>
<br>
I've just had a thought, an old idea of mine is called contract <br>
invalidation. What it does is if you have an argument for say a function <br>
pointer that doesn't have an attribute, the attribute comes off the <br>
called function.<br>
<br>
Useful for opApply, but it might be perfect here too.<br>
<br>
ImportC can default to nothrow, @nogc, @system.<br>
<br>
If you pass in a callback that throws or uses GC, then so does the function.<br>
<br>
Its @system, so compiler isn't making any guarantees in terms of safety <br>
anyway.<br>
<br>
I know Timon wants something more powerful than this, but... it could <br>
work here.<br></blockquote><div><br></div><div>That's an interesting idea in other contexts; but I don't see it's relevant here. This is not an engineering problem that needs to be solved.<br></div></div></div>