PEP318 alternate syntax idea

Stephen Horne steve at ninereeds.fsnet.co.uk
Tue Mar 23 04:39:28 EST 2004


It just occurred to me that if decorators really catch on, there could
be cases where they are applied repeatedly to many functions, and
possibly with many decorators. Combine that with many (and variable
numbers of) parameters per function and readability could be seriously
hit.

In C++, the 'private', 'public' and 'protected' modifiers for class
members are not applied individually to every single member. This
always struck me as being a good thing, and it irritates me that in C#
and java every single definition needs to specify it's visibility.
Yes, there's a default, but you still often get a lot of definitions
that don't match the default. Some classes present a lot of public
member functions as their interface, for instance.

If I were inventing a language, I would allow more modifiers to be
moved away from the definitions/declarations to some kind of preamble.
In C++, for instance, it bugs me if I have to individually declare
each of a group of members to be static, or mutable, or whatever.

With that in mind, how about...

def [staticmethod, ...] :
  #  could use alternate keyword such as 'decorate'

  def a (a1, a2) :
    "this function is decorated"
    ...

  def b (b1, b2) :
    "this function is also decorated"
    ...

def c (c1, c2) :
  "this function is _not_ decorated"
  ...


-- 
Steve Horne

steve at ninereeds dot fsnet dot co dot uk



More information about the Python-list mailing list