Casting away const

bearophile bearophileHUGS at lycos.com
Mon Aug 9 08:31:01 PDT 2010


Steven Schveighoffer:
> But an extern(C) function does not have to be written in C :)

You are right. But that function written in an arbitrary language has to follow the C interface rules and limitations, and among those there is no way to define a variable to be const(char)*.

So in that line of code you are writing something that can't be enforced. Generally D design refuses features that the compiler is unable to verify. So I think an enhancement request to disallow that is good here. An extern(C) call has to specify only things that are understood by the C interface.

On the other hand in C you have const, but its semantics is different. Uhm...

Bye,
bearophile


More information about the Digitalmars-d-learn mailing list