Disallow arrays as pointers

bearophile bearophileHUGS at lycos.com
Sun Oct 30 16:03:23 PDT 2011


Jonathan M Davis:

> from what I understand, 
> it's quite common for D programmers interacting with C code to just pass 
> arrays to C functions without using the ptr property.

That code works with an implicit conversion that saves the typing of 4 more chars, while introducing something that is negative for both newbie D programmers and more trained ones. ".ptr" was introduced in D to avoid this.

In general I find it curious that D design tries to avoid some mistakes of the C design, and to disallow some bug-prone features of C, like some implicit type conversions. But then, it seems that D doesn't take a lot of care to avoid bug-prone "features" that it has introduced, that were not present in C (like the one discussed here, like lax management of strings that represent operators of operator overloading, etc.)

Thank you for your answers,
bye,
bearophile


More information about the Digitalmars-d mailing list