Ticket #143 (closed defect: fixed)

Opened 6 years ago

Last modified 6 years ago

Need to change syntax for pxd function typing

Reported by: dagss Owned by: dagss, robertwb
Priority: blocker Milestone: 0.11
Component: Parsing Keywords:
Cc:

Description

The new inline pxd functions conflicts in syntax with the recently introduced method of having a pure Python function in the .py file and the types for the function in a corresponding pxd file. Cython 0.11 should not be released without fixing the syntax we want to support for the future so I made this a blocker.

The scheme settled on in mailing list:

> > I'm generally -1 on adding new syntax, but what I had wasn't very  
> > clear either. Would it be enough to accept a locals decorator?

I think that's a very clean compromise. You can

a) specify the signature in .pxd files as you would in .pyx files, just
without a function body.

b) write importable inline functions in .pxd files as a function with body,
just as you would in a .pyx file.

c) specify local variable types for a .py implemented function in a .pxd
file by adding a decorator to a function signature, but without providing a
function body.

So, whenever a function signature in a .pxd file has a body at all, it must
be a complete inline function.

I actually don't think that users would intuitively expect the current way
of defining local variables in .pxd files to work.

Note that this may require extending decorator support (in Parsing.py) to cdef functions. They should all probably simply be let through, and then disallowed again (except for @cython.locals) in PostParse?.

Attachments

200.diff Download (1.2 KB) - added by dagss 6 years ago.

Change History

Changed 6 years ago by dagss

  • component changed from Build System to Parsing

Changed 6 years ago by dagss

I think #143 could be partially fixed and made a feature request instead by at least disallowing the current way of typing local vars in pxd files, without necesarrily introducing a new way of doing it.

Changed 6 years ago by dagss

  • owner changed from somebody to dagss

Changed 6 years ago by dagss

Changed 6 years ago by dagss

Fix attached, this can be closed when I get to push it or someone else applies it.

Changed 6 years ago by dagss

NB''' The comments above were for #200, this was for the wrong ticket. (Now where have those edit and delete buttons gone to in this Trac version -- yes, I'm still TRAC_ADMIN...hmmm...)

Changed 6 years ago by dagss

  • owner changed from dagss to somebody

Changed 6 years ago by robertwb

  • status changed from new to closed
  • resolution set to fixed

Changed 6 years ago by scoder

  • status changed from closed to reopened
  • resolution fixed deleted

Changed 6 years ago by scoder

  • owner changed from somebody to dagss, robertwb
  • status changed from reopened to new

Changed 6 years ago by scoder

  • status changed from new to closed
  • resolution set to fixed
Note: See TracTickets for help on using tickets.