Greg Ewing wrote:
> Talking about "the cdef statement" is a bit misleading.
> The way I think of it in Pyrex, there isn't a single
> cdef statement. Rather, there is a cdef prefix that
> can be applied to declarations or suites of declarations
> to give them a different meaning.
That makes it clearer, although the parser function is still called
"p_cdef_statement".
> Since 'pass' is a valid declaration statement (it needs
> to be so that you can have empty suites of declarations),
> 'cdef pass' becomes a slightly fancier way of writing
> an empty declaration. It might look a bit odd, but it
> doesn't do any harm to allow it, IMO.
It's perfectly sufficient to allow "pass" in a cdef block, rather than in
any cdef context. That's what I did in my last fix.
> Another thing you need to be careful not to break is
>
> cdef:
> <statements>
>
> where all the statements in the suite are treated as
> though they were prefixed with cdef (including pass
> statements!).
Thanks, I just checked, and there is a test case for that
(tests/compile/ia_cdefblock.pyx). I still think it makes a lot more sense
to support
cdef:
pass
than to allow
cdef pass
explicitly in the grammar.
Stefan
_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev