[Cython] template types
Dag Sverre Seljebotn
dagss at student.matnat.uio.no
Wed May 6 10:31:43 CEST 2009
Robert Bradshaw wrote:
> On May 5, 2009, at 10:23 PM, Dag Sverre Seljebotn wrote:
>
>> Stefan Behnel wrote:
>>> Lisandro Dalcin wrote:
>>>> On Tue, May 5, 2009 at 6:28 PM, Stefan Behnel wrote:
>>>>> I meant
>>>>>
>>>>> cdef MyType(object) [(T,V)]:
>>>>>
>>>>> here, although I now noticed that there is already the "private
>>>>> type"
>>>>> syntax:
>>>>>
>>>>> cdef public class _Document [ type LxmlDocumentType, object
>>>>> LxmlDocument ]:
>>>>> ...
>>>>>
>>>>> so this won't work straight away either...
>>>>>
>>>> But this would work anyway, right?
>>> Not that easily. You could have both [] parts next to each other,
>>> or just
>>> any one of them. So the parser would fail if you decided to call your
>>> template variable "type", which isn't that a bad name in this
>>> context.
>> How about
>>
>> cdef class A:
>> T, V = cython.template_args(type, type)
>>
>> ?
>
> I prefer the MyType[T,V] syntax. It encapsulates the "meta-type"
> idea, and also the same syntax can be used both in declaring the type
> and instantiating the type.
BTW will this discussion also be used for C++ templates, so that the
consensus seem to be
some_cpp_class[int]
for template instantiation?
--
Dag Sverre
More information about the Cython-dev
mailing list