Casting away const
Lutger
lutger.blijdestijn at gmail.com
Mon Aug 9 12:08:46 PDT 2010
Steven Schveighoffer wrote:
> On Mon, 09 Aug 2010 14:39:58 -0400, Lutger <lutger.blijdestijn at gmail.com>
> wrote:
>
>> bearophile wrote:
>>
>>> Mafi:
>>>> I think, that isn't a good idea.
>>>
>>> I agree, that idea doesn't work well.
>>>
>>> Bye,
>>> bearophile
>>
>> I think it still is a good idea to forbid this in safe mode. Perhaps in
>> trusted
>> too.
>
> Note, this isn't any less safe than defining whatever you want for a C
> function:
>
> extern(C) int strlen(int x);
>
> C has no mangling, so there is no storage of parameter types in the
> symbol. You can call any C function with whatever parameters you want to
> define for them. Making some set of parameters illegal because in some
> cases it might not be true where you don't prevent it in others because
> you can't prove it, is just simply useless.
>
> -Steve
Well you manually add typing, I think that is useful. But come to think of it,
extern(C) functions should not be allowed in @safe code at all, only via
@trusted and then the typing is useful. Perhaps this has been talked about, but
I'm not sure how far @trusted can be allowed to go.
More information about the Digitalmars-d-learn
mailing list