Type safety could prevent nuclear war

Ola Fosheim Grøstad via Digitalmars-d digitalmars-d at puremagic.com
Thu Feb 4 16:12:07 PST 2016


On Friday, 5 February 2016 at 00:03:20 UTC, tsbockman wrote:
> If the same `extern(C)` symbol is declared multiple places in 
> the D source code for a program, the compiler should issue at 
> least a warning if the D signatures don't agree with each other.

I guess D could do it, although this is a rather unlikely source 
for bugs.

C cannot do it. It would be annoying as declarations are file 
local.

C doesn't really build programs, it builds object files that are 
linked into a program.

It makes perfect sense for one compilation unit to type a 
parameter pointer to float  and another unit to type the same 
parameter as a simd-array of floats. The underlying code could be 
machine language. And in machine language there are no types (on 
current CPUs), only bit patterns. So you can have multiple 
reasonable interpretations of the same machine language entry.

A type is a constraint, but it isn't a property of the actual 
bits, it is a language specific interpretation.



More information about the Digitalmars-d mailing list