[Cython] New function (pointer) syntax.

Greg Ewing greg.ewing at canterbury.ac.nz
Thu Nov 6 23:46:53 CET 2014


Robert Bradshaw wrote:
> If you want a hint, the last is something that returns numerical
> integration algorithm given a string name. Yes, you could use
> typedefs, but you shouldn't have to.

I don't find *any* of those particularly easy to read in the third
case, or even the second. Using typedefs to make the intention
clear, even if the syntax doesn't require it, seems entirely
appropriate to me.

> I am curious, when you read "cdef int * p" do you parse this as "cdef
> (int*) p" or "cdef int (*p)"

C syntax is sufficiently well embedded in my brain that I
parse it as "int (*p)", and read it as "p points to an int"
or "p is of type pointer-to-int".

But I don't find myself needing to parse "int * p" very often,
because I always write it as "int *p", and so do most other
people who write C. Whenever I see something like "int * p"
or "int* p", it makes me think it was written by someone who
doesn't understand C very well.

-- 
Greg


More information about the cython-devel mailing list