On Thu, Nov 6, 2014 at 11:30 PM, Ian Henriksen <insertinterestingnameh...@gmail.com> wrote: > On Thursday, November 6, 2014 9:48:53 PM UTC-7, 1989lzhh wrote: >> >> > 在 Nov 7, 2014,02:56,Robert Bradshaw <robe...@gmail.com> 写道: >> > >> > [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), float, float) >> > cdef float ((*H)(char*))(float (*)(float), float, float) >> > >> > vs >> > >> > cdef float -> float F >> > cdef (float -> float, float, float) -> float G >> > cdef (char*) -> (float -> float, float, float) -> float H >> > >> > vs >> > >> > cdef lambda float: float F >> > cdef lambda (lambda float: float), float, float: float G >> > cdef lambda (char*): lambda: (lambda float: float), float, float: >> > float H >> > >> > >> > 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. especially for the first. >> > >> Here are numba kind function annotation, I guess it may fit in here. >> cdef float(float) F >> cdef float(float(float), float, float) G >> cdef float(float(float), float, float)(char*) H >> I personally feel this kind of annotation is more packed that using ->. >> >> Regards, >> Liu zhenhai > > > Here are my thoughts, for what they're worth. > I actually really like the arrow syntax. It matches the way > that the domains and ranges of functions are often written > mathematically. On the other hand, it does conflict with > the syntax from C. > > The syntax from Numba is a really good way to do this as well. > It is just as clear and doesn't conflict with C. Strictly speaking, > it isn't Python, but it would be nice to have similarities in the > syntax for the different packages. > > The C syntax is not intuitive. The only benefit there is the > overlap with C. For something this simple, learning the new > syntax is easy enough.
+1 > The lambda syntax strikes me as an intuitive solution, but it > isn't particularly clean or concise. If the syntax is going > to change, it would be good to change it to something nicer > than that. I don't think this one would be worth making the change. > > All things considered, the Numba syntax looks like the best idea. > The arrows are intuitive as well, but the overlap with the syntax > from C could be a bad thing. Yeah, I'm kind of leaning that way too. > Thanks for looking into this! Thanks for the feedback. - Robert _______________________________________________ cython-devel mailing list cython-devel@python.org https://mail.python.org/mailman/listinfo/cython-devel