[Cython] New function (pointer) syntax.

Robert Bradshaw robertwb at gmail.com
Mon Nov 10 21:23:37 CET 2014


On Mon, Nov 10, 2014 at 6:25 AM, Dima Pasechnik <dimpase at gmail.com> wrote:
> On 2014-11-06, Robert Bradshaw <robertwb at gmail.com> wrote:
>> I'd like to propose a more pythonic way to declare function pointer
>> types, namelye
>>
>>     type0 (*[ident])(type1, type2, type3)
>>
>> would instead become
>>
>>     (type1, type2, type3) -> type0 [ident]
>>
>> I have a pull request up at https://github.com/cython/cython/pull/333;
>> what do people think?
>
> we had a discussion with Volker about this few weeks ago - in my Cython code I
> needed to do, as he suggested, a workaround like this:
>
>    int* vlamatrix  "(int (*)[])" (int*) # a hack to get int (*)[] through cython
>
> This was for 2-dim arrays of variable length, and looks similar to the
> stuff here.
>
> IMHO it would be good to address this, too.

Yeah.

> I'd rather stick to C99 conventions in Cython.
> To me, using '->' for types looks way too close to what is used, with
> different semantics,  in functional languages like Haskell or Coq.

Actually, the proposed use of '->' *is* identical to Haskell in
semantics, i.e. "int -> int" is how you write a function taking and
returning an int. Of course in Python one has a single argument tuple
as input rather than currying.


More information about the cython-devel mailing list