Translating C const

Jacob Carlborg doob at me.com
Sat May 26 04:05:00 PDT 2012


On 2012-05-26 01:17, Jonathan M Davis wrote:

>> Ok I see, thanks. Is that true for fields in structs and global
>> variables as well?
>

> Anyway, I suppose that that's not terribly conclusive, but the lack of ability
> to have non-transitive const declarations is a bit of a problem when dealing
> with extern(C) functions given that it has behaviors that D _doesn't_ have. As
> far as I can see, whether constifying the whole thing or making it all mutable
> makes more sense really depends on what the C function is doing and how it's
> called, which naturally doesn't go well with a tool like you're creating.
> You'll probably have to go with what is _least_ likely to cause bugs and then
> let the programmer adjust it as needed.
>
> - Jonathan M Davis

What do you think about translating the C const to D where possible and 
then just leave it mutable in all other cases. Then assuming the C code 
will not cast away const. A user is always free to edit the bindings 
manually.

-- 
/Jacob Carlborg


More information about the Digitalmars-d-learn mailing list