On 06/02/2011 06:39 PM, Robert Bradshaw wrote:
In looking at merging fused types, it's time to nail down the syntax.
The current implementation is
ctypedef cython.fused_type(list, dict, object) fused_t
This requires an addition to the grammer to allow the "call" syntax in
a type declaration, as well as special casing to make it allowed only
in a typedef. What about
cython.fused_type[list, dict, object].
One advantage is that indexing is already valid in type declarations,
and its the typical syntax for parameterized types. Thoughts? Any
other ideas?
I don't really like overloading [] even more, and I think () (or,
perhaps, 'fused_type([list, dict, object])').
But I don't feel very strongly about it.
If you only want this allowed in typedefs, then, being puristic, I think
that really a "fused type" is really different from a ctypedef, and that
it would warrant something like a new keyword.
cdef fusedtype [list, dict, object] fused_t
That's rather horrible, but you get the gist. The thing is, once you use
a ctypeudef, you really should allow
def f(fused_type(float, double) x, fused_type(float, double) y): ...
but then, how many fused types do you have, one or two?
So this makes it seem to me that using ctypedef is a rather horrible hack.
But, like I said, I don't feel strongly about this.
P.S. Anyone remember buffers and C++ templated types are dissallowed
as typedefs?
As for buffers I just think I never got around to it...
Dag Sverre
_______________________________________________
cython-devel mailing list
cython-devel@python.org
http://mail.python.org/mailman/listinfo/cython-devel