On Thu, Apr 28, 2011 at 12:48 PM, mark florisson <markflorisso...@gmail.com> wrote:
> So I fixed all that, but I'm currently wondering about the proposed > cython.typeof(). I believe it currently returns a string with the type > name, and not the type itself. Yes. This is just because there's not really anything better to return at this point. We should "fix" this at some point in the future. > So I think it would be inconsistent to > suddenly start allowing comparison with 'is' and 'isinstance' and > such. I'm open to other suggestions, but would like an expression that resolves at compile time to true/false (and we need to do branch pruning on it). Note that type() is not good enough, because it has different semantics, i.e. cdef object o = [] typeof(o), type(o) so lets not touch that one. > I'm also wondering if it would be useful to allow actual type > retrieval, which could be used in declarations and casts. For instance > consider fusing two structs with the same attribute name but different > attribute types. Perhaps in your code you want to introduce a variable > compatible with such a type, e.g. consider this: > > ctypdef struct A: > int attrib > > ctypedef struct B: > char *attrib > > ctypedef cython.fused_type(A, B) struct_t > > cdef func(struct_t mystruct, int i): > cdef cython.gettype(mystruct.attrib) var = mystruct.attrib + i > ... > > What do you think? Yes, I was thinking that would be supported as well. - Robert _______________________________________________ cython-devel mailing list cython-devel@python.org http://mail.python.org/mailman/listinfo/cython-devel