On Jan 7, 2010, at 12:34 PM, Neil Ludban wrote:

> On Jan 7, 2010, at 3:08 PM, Robert Bradshaw wrote:
>> On Jan 7, 2010, at 8:40 AM, Neil Ludban wrote:
>>
>>> Forgot to ask, what if I wanted to add final/inline/whatever to the
>>> entire class?
>>
>> I don't think it's possible to prevent a class from being subclassed
>> in Python-land. (Well, not without checking raising some kind of a
>> runtime exception on instantiation or something like that...)
>>
>> - Robert
>
> Classes defined in extensions must explicitly indicate that they
> support subclassing from pure Python.  NoneType and bool are core
> types that don't, there may be others.

Ah, I did not know that. That does make a final modifier more  
attractive. This is a larger change to the language than allowing  
inline methods (with an error if one attempts to override them).

> The intended point was that the semantics of making a class "final"
> are understood and would imply the requested optimizations, while
> the "inline" keyword wouldn't fit at all in this context.


I think it depends on the perspective you're coming from. Is the  
intent to have the method inlined, which implies final as a  
consequence, or is the intent to have the method final, with possible  
inlining as an optimization detail?

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? On another note, I assume inline  
methods could be placed in pxd files if desired as well?

As for decorators vs. inline (pun intended) function modifiers, we  
should certainly support both.

- Robert

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

Reply via email to