Type safety could prevent nuclear war

Daniel Murphy via Digitalmars-d digitalmars-d at puremagic.com
Fri Feb 5 03:42:18 PST 2016


On 5/02/2016 10:07 PM, tsbockman wrote:
>
> I think it makes sense (when actually linking to C) to allow stuff like
> druntime's creative use of overloads. The signatures of the two
> bsd_signal() overloads are compatible (from C's perspective), so why not?
>
> However, multiple `extern(C)` overloads that differ in the number or
> size of arguments should trigger a warning. Signed versus unsigned or
> even int versus floating point is more of a gray area.
>

That's what I meant by binary compatible.

> Overloads with conflicting pointer types should definitely be allowed,
> but ideally the compiler would force them to be marked @system or
> @trusted, since there is an implied unsafe cast in there somewhere.

Safety on C functions is always going to need to be hand verified, the 
presence of overloads doesn't change that.  Conflicting pointer types 
are pretty much the same as a function taking void* - all the unsafe 
stuff is on the other side and invisible to the D compiler.


More information about the Digitalmars-d mailing list