Johannes Wienke wrote: > Am 06/04/2008 11:59 PM schrieb Dag Sverre Seljebotn: >> Johannes Wienke wrote: >>> Am 06/04/2008 07:47 PM schrieb Stefan Behnel: >>>> If you *really* want None, then you can use something like this: >>>> >>>> cdef inline stringOrNone(char* value): >>>> if value is NULL: return None >>>> return value >>> That's exactly what I'm doing now but that's error-prone as you have to >>> do this manually and can forget it. >> >> (Sorry about telling you to reread, I can see that you commented on it >> already.) >> >> Well, in my mind, this is a reason for supporting Stefan in removing >> auto-coercion of char* to Python strings altogether (that is suggested >> once down in those unicode discussion threads, right Stefan?). Then >> you would get a nice compiler error when you forget it, and it won't >> be error-prone. > > Now with the context of encoding issues I can see the point. Things you > don't have to think of to often as Java developer. ;) Removing the > conversion then would be a good idea. Compiler warnings are of course > the best bug prevention. On the other hand this really handy... Hard to > decide.
To further expand on this point (for the purposes on the ongoing month-long argument about char* behaviour on this mailing list): If you were doing the same thing in Java (i.e. interfacing with a C library), I can tell you that you *would* have to care about encoding issues :-) There's no way Java would have let you create a string without specifying the encoding somewhere. -- Dag Sverre _______________________________________________ Cython-dev mailing list [email protected] http://codespeak.net/mailman/listinfo/cython-dev
