Re: [Cython] New function (pointer) syntax.

2014-11-10 Thread Robert Bradshaw
On Mon, Nov 10, 2014 at 1:10 PM, Dima Pasechnik wrote: > On 10 November 2014 20:23, Robert Bradshaw wrote: >> On Mon, Nov 10, 2014 at 6:25 AM, Dima Pasechnik wrote: >>> On 2014-11-06, Robert Bradshaw wrote: I'd like to propose a more pythonic way to declare function pointer types, nam

Re: [Cython] New function (pointer) syntax.

2014-11-10 Thread Dima Pasechnik
On 10 November 2014 20:23, Robert Bradshaw wrote: > On Mon, Nov 10, 2014 at 6:25 AM, Dima Pasechnik wrote: >> On 2014-11-06, Robert Bradshaw wrote: >>> I'd like to propose a more pythonic way to declare function pointer >>> types, namelye >>> >>> type0 (*[ident])(type1, type2, type3) >>> >>>

Re: [Cython] New function (pointer) syntax.

2014-11-10 Thread Robert Bradshaw
On Mon, Nov 10, 2014 at 6:25 AM, Dima Pasechnik wrote: > On 2014-11-06, Robert Bradshaw 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) -> typ

Re: [Cython] New function (pointer) syntax.

2014-11-10 Thread Dima Pasechnik
On 2014-11-06, Robert Bradshaw 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/cyth

Re: [Cython] New function (pointer) syntax.

2014-11-08 Thread Robert Bradshaw
On Sat, Nov 8, 2014 at 3:19 PM, C Blake wrote: >>But I admit it's hard to come up with an objective measure for how >>good a syntax is...if it's natural to you than that's great. > > I think those queries you mention will mostly be biased by the squeakier > wheels being more beginning people and t

Re: [Cython] New function (pointer) syntax.

2014-11-08 Thread C Blake
>But I admit it's hard to come up with an objective measure for how >good a syntax is...if it's natural to you than that's great. I think those queries you mention will mostly be biased by the squeakier wheels being more beginning people and that's not a very good argument or metric. I agree an o

Re: [Cython] New function (pointer) syntax.

2014-11-07 Thread Robert Bradshaw
On Fri, Nov 7, 2014 at 11:29 AM, C Blake wrote: > Robert Bradshaw robertwb at gmail.com wrote: >>Quick: is that a pointer to an array or 10 pointers to ints? Yes, I >>know what it is, but the thing is without knowing C (well) it's not >>immediately obvious what the precedence should be. > > If you

Re: [Cython] New function (pointer) syntax.

2014-11-07 Thread C Blake
Robert Bradshaw robertwb at gmail.com wrote: >Quick: is that a pointer to an array or 10 pointers to ints? Yes, I >know what it is, but the thing is without knowing C (well) it's not >immediately obvious what the precedence should be. If you're gonna pick something e.g like that, it should not be

Re: [Cython] New function (pointer) syntax.

2014-11-07 Thread Robert Bradshaw
On Thu, Nov 6, 2014 at 1:35 PM, C Blake wrote: > I think you should just use the C declarator syntax. Cython already > allows you to say "cdef int *foo[10]". Quick: is that a pointer to an array or 10 pointers to ints? Yes, I know what it is, but the thing is without knowing C (well) it's not im

Re: [Cython] New function (pointer) syntax.

2014-11-06 Thread Stefan Behnel
Stefan Behnel schrieb am 07.11.2014 um 08:18: > We could fix some of that by allowing > > cdef nogil: > cdef char*(float x, int y) get_gil > > But then, that's adding yet another special case. ... except when it's already supported, which it turns out to be... Stefan __

Re: [Cython] New function (pointer) syntax.

2014-11-06 Thread Stefan Behnel
1989lzhh schrieb am 07.11.2014 um 05:48: >> 在 Nov 7, 2014,02:56,Robert Bradshaw 写道: >> Here's some proposed function pointer syntaxes; which are the most >> obvious to understand/read/remember? Can you figure them out? >> >>cdef float (*F)(float) >>cdef float (*G)(float (*)(float), float, f

Re: [Cython] New function (pointer) syntax.

2014-11-06 Thread C Blake
I think you should just use the C declarator syntax. Cython already allows you to say "cdef int *foo[10]". Declarators aren't bad - just poorly taught, though I can see some saying those are the same thing. More below. I absolutely like the declarator one the most, and the lambda one second most

Re: [Cython] New function (pointer) syntax.

2014-11-06 Thread Greg Ewing
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

Re: [Cython] New function (pointer) syntax.

2014-11-06 Thread Robert Bradshaw
On Thu, Nov 6, 2014 at 11:56 AM, Stefan Behnel wrote: > Robert Bradshaw schrieb am 06.11.2014 um 19:56: >> On Thu, Nov 6, 2014 at 9:59 AM, Stefan Behnel wrote: >>> Robert Bradshaw schrieb am 06.11.2014 um 18:15: This becomes especially clear for return types, e.g. cdef ((float -

Re: [Cython] New function (pointer) syntax.

2014-11-06 Thread Stefan Behnel
Robert Bradshaw schrieb am 06.11.2014 um 19:56: > On Thu, Nov 6, 2014 at 9:59 AM, Stefan Behnel wrote: >> Robert Bradshaw schrieb am 06.11.2014 um 18:15: >>> This becomes especially clear for return types, e.g. >>> >>> cdef ((float -> float, float, float) -> float) >>> get_integrator(char* algo

Re: [Cython] New function (pointer) syntax.

2014-11-06 Thread Robert Bradshaw
[Cc'ing elsewhere for more feedback. Also top-posting for initial impressions before the discussion.] Here's some proposed function pointer syntaxes; which are the most obvious to understand/read/remember? Can you figure them out? cdef float (*F)(float) cdef float (*G)(float (*)(float), f

Re: [Cython] New function (pointer) syntax.

2014-11-06 Thread Stefan Behnel
Robert Bradshaw schrieb am 06.11.2014 um 18:15: > On Thu, Nov 6, 2014 at 12:29 AM, Stefan Behnel wrote: >> Robert Bradshaw schrieb am 06.11.2014 um 08:34: >>> I'd like to propose a more pythonic way to declare function pointer >>> types, namelye >>> >>> type0 (*[ident])(type1, type2, type3) >>>

Re: [Cython] New function (pointer) syntax.

2014-11-06 Thread Robert Bradshaw
On Thu, Nov 6, 2014 at 12:29 AM, Stefan Behnel wrote: > Robert Bradshaw schrieb am 06.11.2014 um 08:34: >> 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

Re: [Cython] New function (pointer) syntax.

2014-11-06 Thread Stefan Behnel
Robert Bradshaw schrieb am 06.11.2014 um 08:34: > 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] Not convinced. Looks quite magic, very dif

[Cython] New function (pointer) syntax.

2014-11-05 Thread Robert Bradshaw
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? - Robert ___