Robert Bradshaw wrote:
> On May 6, 2009, at 12:47 AM, Dag Sverre Seljebotn wrote:
>
>> Stefan Behnel wrote:
>>> 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.
>> I disagree with this principle. (I guess it might be a matter of taste
>> in the end, so I'll just state my opinion and try not to drag this on
>> for too long.)
>>
>> In perhaps about a year, with Python 3 argument decorators (def foo(x:
>> int) -> float) and a bit of type inference, "pure Python mode" could
>> actually become as convenient as Cython syntax and the preferred
>> syntax
>> we'd teach new users in my opinion.
>
> I think "cdef int i,j,k" is in always going to be easier than
>
> i = cython.declare(int)
> j = cython.declare(int)
> k = cython.declare(int)
>
> but in general I agree with this philosophy.
Yes, like I said, type inference would be needed. So perhaps more than a
year.
But type inference wouldn't need to be that great, just at a minimum
pick up manual hints like
i = cython.int(func_returning_any_type())
and if i is never assigned to anything than known cython.int instances,
then type it accordingly.
I've also been thinking about doing things like
def foo(x: int,
y: int,
_,
localvar1: float,
localvar2: float):
...
but it is too ugly :-(
In Py3 we could also abuse the new
def f(x, *, kwonly): ...
syntax in the same way, but it already has a use so probvably
not...but I'm still playing with variations on the theme.
> Only if there's a non-pure Python syntax that's a lot cleaner (which
> I think the class Foo[T] is).
Yes, I was basing what I said on writing a template to be much rarer
(and done by a lot fewer users) and so not "needing" a clean syntax; I
agree that it is cleaner.
(I'm still concerned about adding Yet Another Scope Rule (I haven't even
learned the current ones fully yet!) for this, but mostly on the
philosophical level, in practice it would work as the user expects.)
--
Dag Sverre
_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev