Robert Bradshaw wrote:
> On May 5, 2009, at 10:23 PM, Dag Sverre Seljebotn wrote:
>> 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.

+1


>> (The reason for the arguments: In C++ you can have stuff like ints in
>> template arguments as well, might as well leave the possibility
>> open even
>> if only passing type is allowed for now).
>>
>> This even puts T and V in the proper scope for @cython.locals
>> declarations, e.g. this passes through (and could even be made to
>> do the checks) in pure Python:
>>
>> @cython.cdef
>> class A:
>>     T, V = template_args(type, type)
>>     @cython.locals(a=T, b=v)
>>     def foo(self, a, b): ...
>
> I'd rather see the pure Python mode decorate the class than have a
> magic method, but I don't think decorators get applied soon enough to
> inject variables into the scope.

I wouldn't care so much about that for now. Whatever declaration we
choose, it's easily added when the feature itself is there, and I think
parametrised types are such an advanced feature that users can well wait
for it to become available in pure Python mode.

The priorities should be to make the feature simple and well readable in
Cython code, and then 'somehow' available in Python code.

Stefan

_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev

Reply via email to