On Tue, May 5, 2009 at 6:18 PM, Stefan Behnel <[email protected]> wrote: > > Lisandro Dalcin wrote: >> At some point, I've started to use some hackery via a registry and a >> custom class abusing of __getitem__() to support on Python side: >> >> myinst = MyClass[sometype](args) >
> Actually, now that I see this - it actually makes sense to think of a > parametrised type as a meta-type that maps types to types, so a mapping > syntax makes sense here. Nice! You just added another point for me to like "[]", the mapping concept fits well IMHO... > If you have more than one type parameter, it'd > look like this: > > myinst = MyClass[(sometype, someothertype)](*args) > Why the tuple? This should work just fine: myinst = MyClass[sometype, someothertype](*args) thoug the MyClass.__getitem__() will receive a tuple actually... (sugar added to Python slice syntax long ago following request of Numeric) > and the concrete type would basically be 'looked up' at compile time. > > It doesn't directly map to an 'obvious' declaration syntax, but I guess > > cdef MyType(object) [(sometype, someothertype)]: > ... I would prefer: cdef MyType[sometype, someothertype](object): -- Lisandro Dalcín --------------- Centro Internacional de Métodos Computacionales en Ingeniería (CIMEC) Instituto de Desarrollo Tecnológico para la Industria Química (INTEC) Consejo Nacional de Investigaciones Científicas y Técnicas (CONICET) PTLC - Güemes 3450, (3000) Santa Fe, Argentina Tel/Fax: +54-(0)342-451.1594 _______________________________________________ Cython-dev mailing list [email protected] http://codespeak.net/mailman/listinfo/cython-dev
