[Cython] Prototype for parametrized types
Dag Sverre Seljebotn
dagss at student.matnat.uio.no
Sun Mar 9 22:25:04 CET 2008
> Regarding function parameters, yes, so that's definitely an advantage. But
> that does not yet give you type annotations for variables. If I understand the
> original proposal right, those would become
>
> cdef type.param(1,2,3) varname
>
This is going to be a repeat of what Robert already said, but I feel it
is important that the point gets through:
The original proposal did not say anything about how to declare a
variable. It does a) say something about how to declare/use a type,
anywhere a type might be needed, b) use the current syntax for the
examples, because using a non-current syntax for examples would be silly
(where would one stop? type inference is a real possibility, should I
assume that for the examples?)
We all agree that decorating variables in real Python is a real problem,
but this proposal doesn't change anything for better or worse
considering that. What this proposal says is that, given a hyopthetical
CEP102 that proposes the following syntax for declaring types of
in-function variables:
i = typed(int)
then a consequence of my proposal is that it is legal to also say
v = typed(cpp.vector(int))
On the other hand, if the hypothetical CEP103 gets accepted instead
which says "screw Python syntax" and makes it
i: int
also inside functions, then a consequence of my proposal is that it is
legal to also say
v: cpp.vector(int)
inside functions. See how they are orthogonal, to use Robert's phrase?
I'm sorry if the proposal was unclear about this.
Dag Sverre
More information about the Cython-dev
mailing list