Fri, 29 Apr 2011 10:23:55 +0200, mark florisson wrote: [clip] > Ok, branching on the type sounds fine to me. It brings one problem > though: because you cannot declare the variables of your variable type > (the type of say, mystruct.attrib), you will need to do multiple > declarations outside of your branches. So in my example: > > cdef func(struct_t mystruct, int i): > cdef string_t string_var > cdef int int_var > > if typeof(mystruct) is typeof(int): > int_var = mystruct.attrib + i > ... > else: > string_var = mystruct.attrib + i > ... > > But this is probably not a common case, so likely not an issue.
Are you planning to special-case the "real_t complex" syntax? Shooting from the sidelines, one more generic solution might be, e.g., ctypedef cython.fused_type(A, B) struct_t ctypedef cython.fused_type(float, double, paired=struct_t) real_t ctypedef cython.fused_type(int_t, string_t, paired=struct_t) var_t and just restrict the specialization to cases that make sense. -- Pauli Virtanen _______________________________________________ cython-devel mailing list cython-devel@python.org http://mail.python.org/mailman/listinfo/cython-devel