On Thu, Oct 3, 2013 at 1:23 PM, Stefan Behnel <stefan...@behnel.de> wrote: > Greg Ewing, 03.10.2013 14:10: >> Robert Bradshaw wrote: >>> cdef int *a, b, c, *d[3] >>> >>> is IMHO quite ugly but also adds a lot of complexity to the parser. >>> What if instead we required >>> >>> cdef int* a >>> cdef int b, c >>> cdef int[3]* d > > The last line looks ambiguous, BTW, hadn't even noticed it before. Is that > an array of int pointers or a pointer to an array (pointer)? We should make > sure the way this is declared is really obvious and not unexpected to C users. > > >> What would be the benefit of this? You're proposing to change >> from something identical to C declaration syntax, which is >> second nature for a great many people, to something that >> looks deceptively like C syntax but isn't. > > The reasoning is that the C syntax is error prone and less readable than it > could be, because you have to spot stars in the right places of a > potentially long list of variable names to know if something is a value or > a pointer. If there was only one type declaration, right after the cdef, it > would be much clearer. It would just say: "this is a list of variables > declared as int*", not mixing any further types into it. > > Also, C is only second nature to some people. A great many people actually > use Cython specifically to *avoid* having to write C.
The two halves of this email seem to sort of contradict each other, don't you think? At least the C syntax has the advantage that it's well-defined and many people *do* know it (and if they don't then there are bazillions of references around, plus you can just copy it out of header files if you're wrapping a C library), whereas as noted above, in fact there are *no* people who know how to look at int[3]* and be confident about what it means, even you...? (I'm not against improving on C in general, but I'm far from convinced that there's any syntax for encoding C types that's sufficiently better than what C does to be worth the switching costs.) If what really bothers you is having objects of different types declared within the same statement then you could just litigate *that* out of existence directly... not convinced this would be worthwhile (though I do tend to use that style myself already), but it seems more viable than trying to reinvent C's type syntax. -n _______________________________________________ cython-devel mailing list cython-devel@python.org https://mail.python.org/mailman/listinfo/cython-devel