Hi,

Am 06/04/2008 11:36 PM schrieb Dag Sverre Seljebotn:
Johannes Wienke wrote:
Hi,

Am 06/04/2008 09:54 PM schrieb Stefan Behnel:
Johannes Wienke wrote:
Am 06/04/2008 07:47 PM schrieb Stefan Behnel:

To my mind only char pointers would need this extra behavior as they
have a somewhat special role in C because of the absence a string type.
Then why None and not ''? And why None and not a ValueError?
Because None has for python the same meaning as NULL in C. ValueError
would be another possibility. Nevertheless if NULL can be a legal value
for the rest of that function, this would be as awkward to handle as the
explicit check for NULL if I only want a safe print statement.
>
char* is usually used to call into legacy C code, if you need to print them I'd argue that in most cases you are converting to char* one step too early. But if you really need to print char* directly,

Well but for my purposes the legacy code calls into cython.

print "%s ... %s" % (cb2str(a), cb2str(b))

What is that function? I have never seen that before?

Conversion problems are of course a much better reason not to implement this than speed reasons.

[...]

However, Cython cannot be Java because C is not Java. It will always be possible to do (<int*>0)[0] and segfault; that's part of the deal when writing C.

That's true. But that's a much more obvious bug.

Cython can very well work safely; simply use Python strings!; avoid all pointers, etc. Java doesn't have a char* either. The Cython equivalent to java.lang.String is a Python str, not a char*!

But I can't, because the pugins I have to wrap work in C and there may be other situations where an existing C API requires callbacks and so on.

- Johannes

Attachment: signature.asc
Description: OpenPGP digital signature

_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev

Reply via email to