--- Comment #4 from bearophile_h...@eml.cc 2011-06-30 18:57:48 PDT ---
(In reply to comment #3)
> Your suggestion doesn't help at all with remembering to use zero-terminated
> strings when calling C code.
> Are your
> suggestion only helps as far as the type system goes if all of the C functions
> in druntime or wherever use CcharPtr instead of char*, since if the function
> takes char*, you can still pass a string directly to them even if you have
> CcharPtr to use if you want to. So, I don't see how this suggestion helps much
> of anything.
With extern(C) you are free to give to C functions a signature that you want.
In this example strlen() is meant as an example of random user-defined function
from some third-party C lib. Maybe using strlen() is not a clear enough
example, I have to use the frobaz() C function instead.
The idea here is that you define their signature using something like CcharPtr.
If you do this, the type system will catch your bugs because you can't pass a
char* to those C functions.
Similar tricks, or ones based on more complex type system features, allow you
to kill bugs in F# code, ATS code, etc.
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------