Dag Sverre Seljebotn, 11.01.2010 12:37:
> Stefan Behnel wrote:
>> Robert Bradshaw, 07.01.2010 22:06:
>>> The inline keyword is nice because we already use it for functions  
>>> (where the final keyword makes no sense). I think it's probably worth  
>>> introducing both keywords, where inline would control emission of the  
>>> C inline directive. (Of course for non-inline final methods, the C  
>>> compiler could decide whether or not to actually inline.) A class  
>>> could be final, with the same semantics as java. One question is would  
>>> inline imply final, or require it?
>> It makes no sense without final, so it should imply it (and certainly not 
>> require it).
> 
> Actually, in code like this
> 
> a = MyClass()
> a.foo()
> 
> the compiler would be able (in theory) to infer the exact type of "a" 
> and treat any method calls on it as final (skip vtable)

I think that's a worthy optimisation anyway. It's mostly a generalisation 
of ticket #3.

http://trac.cython.org/cython_trac/ticket/3

And this is totally orthogonal to the whole final/inline discussion. It 
only relies on the "missing __new__ support" assumption that we already make.


> and then whether INLINE is declared or not C-side is an orthogonal issue.
> 
> I.e. "cdef inline foo(self)" could mean "allow overriding the method, 
> but make it inline in situations where the vtable can be skipped".
> 
> Not that I think there's a real use for this...

There almost certainly isn't. Unless the method is declared final, a 
programmer can't rely on Cython taking the decision to skip the vtable 
lookup in a specific case, so the result would be more or less 
unpredictable. Given that the C compiler is free to inline function calls 
anyway, even if not declared inline, applying the inline modified in this 
specific case sounds rather useless.

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

Reply via email to