why not extending the syntax for classes, too ?

Bengt Richter bokr at oz.net
Sun Feb 9 13:53:03 EST 2003


On 7 Feb 2003 08:10:21 -0800, mis6 at pitt.edu (Michele Simionato) wrote:

>Within the proposals of extending the function syntax,
>reported on the python-dev summary recently posted on c.l.p.,
>I like the most the proposal with "is", as for instance in
>
>def double(x) is staticmethod:
>    return 2*x
>
How about specialization or specialty or kind or narrowly or becomes?
 def double(x) specialization staticmethod:
     return 2*x

 def double(x) becomes staticmethod:
     return 2*x

 def double(x) kind staticmethod:
     return 2*x

>I like the "is" syntax more than the syntax with "as" and the syntax 
>with the square brackets, especially because with "is"  it would be
>natural to extend the notation for classes, using metaclasses as class
>descriptors. Metaclasses are typically denoted by adjectives and thus,
>instead of writing, for instance
>
>class C(B): 
>    __metaclass__=Traced 
>    #assuming Traced is a metaclass adding tracing capabilities
>
>one could write
>
>class C(B) is Traced:
>    #This is much more readable

 class C(B) specialization Traced:
     #This is much more readable

 class C(B) becomes Traced:
     #This is much more readable

Or we could use a suffix:

 def double(x) staticmethod'ly:
     return 2*x

 class C(B) Traced'ly:
     #This is much more readable

;-)

Regards,
Bengt Richter




More information about the Python-list mailing list