Virtual functions are virtually invisible!

rantingrick rantingrick at gmail.com
Sun Jul 3 18:55:56 EDT 2011


Hello Folks!

In my quest to uncover the many asininities contained within the
tkSimpleDialog.py module i found myself contemplating some the very
fundamental aspects of the Python language proper. And this is aspect
be... "Pythonic notation".

But before i introduce you to my latest discovery of collective
ineptitude i want to discuss some of the great pythonic notations we
already enjoy.

In the beginning, Mr. Van Rossum (in a stroke of complete brilliance i
might add!) stumbled upon the idea of syntactical notation and he
seized upon it! We all know how python uses indention to denote scopes
(and i just love this aspect about the language!) but my next favorite
notation is the leading and trailing double underscores that wrap
special method names[1] Because they just JUMP out at you whilst
reading code (and they should!). Even if they only say...

 """Hey, i am special and you should only care about me if you are an
experienced pythonista, otherwise nothing to see here, move along
lad!"""

Actually i did not realize just HOW important this notation was to my
code comprehension until i started tinkering with another language
called "Ruby" (who BTW does not use any notation for this matter).
Ruby doesn't use any special notation so all the member methods just
blend into the crowd.

Nothing jumps out and says "HEY, I'M SPECIAL, LOOK AT ME"... instead
you start to get sea sick from the homogeneous structure of it all.
You cannot quickly categorize the method hierarchy without extensive
reading and wasted time. This is a shame!

But this gushing over underscores is not the subject of my thread
today, what concerns me is the fact that virtual methods in derived
classes just blend in to the crowd. For me this presents major
problem, because i don't know what "behind the scenes" actions are
going to take place without a very personal relationship with the
underlying code base. More wasted time!

So what i am proposing is some way to differentiate methods that have
been clobbered by the derived class. And it's not the fact that they
have been clobbered that is of any concern to me, NO, what concerns me
is that i don't know what "invisible" side effects are taking place
"behind-the-scenes",  much less which methods are the root of such
invisible side effects.

You know as Pyhthonista's we always frown on syntactic decorators
HOWEVER like all good things these visual cues are best taken when in
moderation. I believe in these cases syntactic decorators are not only
needed but they are warranted!

Of course the simplest solution is a doc string explaining the case to
a reader. But as we all know even pyhtonista's refuse to follow the
style guide so this will be a non starter. I think we really need some
sort of visual cue in the form of forced syntactical notation (just
like the special method underscores).

[1] http://docs.python.org/reference/datamodel.html#special-method-names



More information about the Python-list mailing list