On Mar 10, 2008, at 12:10 AM, Stefan Behnel wrote: > Hi, > > Dag Sverre Seljebotn wrote: >> 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 > > Sure. > > >> 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)) > > I hope it won't be that syntax, as this is what an assignment from > a function > call looks like, this is not a declaration. Declarative syntax > should not be > easily confused with syntax that results in real code doing something.
My suggestion would be something of the form i = cython.types.int v = cython.types.cpp.vector(int) This would also have the right feel to it if type inference is done (though in the this case, assignment to i of a non-int would not change the type of i). > But I was suggesting that there is currently an asymmetry between > how we can > declare types in interfaces (i.e. function signatures) and inside code > fragments. Pyrex has that already, as you don't need a cdef in > signatures, but > it doesn't get any better with PEP 3107. So the only advantage that a > Python-like signature gives us is that it would be valid Python > code if used > in signatures. The more important place where type declarations are > used (i.e. > inside the code), is not impacted. True. Function signatures are a special case because the syntax of a function declaration is constrained enough that type information is not easily confused with anything else (for both humans and computers). As it has been mentioned, I'm hopeful type inference within a function, with typed inputs, can go a long way towards making local type declarations unnecessary. - Robert _______________________________________________ Cython-dev mailing list [email protected] http://codespeak.net/mailman/listinfo/cython-dev
