preparing for const, final, and invariant

Walter Bright newshound1 at digitalmars.com
Sun May 20 11:46:49 PDT 2007


torhu wrote:
> If you've got a C library with a header file containing this:
> 
> // C header file
> void f(const char* p);
> 
> Is there any reason why you should think twice before turning it into 
> this D code, and link it with the C library, not knowing anything about 
> the implementation of f?
> 
> // D import module
> extern (C) void f(in char* p);
> 
> 
> Without reading the docs for f, would it be better to just go with 
> 'const'?  In that case it won't be backwards compatible with D 1.0 
> anymore.  If I get the meaning of 'scope' correctly, that's the one that 
> can cause problems here.

I'd go with:

	f(const char* p);

because that expresses the C semantics. Using 'in' will cause problems 
if f() stores p somewhere.



More information about the Digitalmars-d-announce mailing list