"Amir Michail" <am******@gmail .com> wrote in message news:<cf******* *@odak26.prod.g oogle.com>...
I was wondering if there is a tool that will perform some heuristic
checking of actual and formal parameters to warn about likely errors.
Such a tool could check that formal and actual parameters have similar
names.
For example:
def plot(x,y): ...
plot( x1, y1 ) # ok
plot( y1, x1 ) # not ok, but this is ok: plot (x=y1, y=x1)
I'm not sure how generally useful this would be. There are just too
many circumstances where the name in the definition and the name you
call with are legitimately quite different:
def plot(x, y):
....
plot(square.wid th, square.height)
for column in range(8):
for row in range(8):
move_pawn_to(co lumn, row)
plot(column, row)
for i in range(10):
for j in range(10):
plot(i,j) #along with other stuff using the loop variables
def write_log(strin g_to_send): # probably a log.write method in
real life
....
write_log(serve r.error_message )
write_log(user. username)
def wait_for_connec tion(socket):
....
wait_for_connec tion(servers["yahoo"])
It _might_ be somewhat useful to have something that detects ONLY when
you are calling with similar names in a different order. Even that
isn't necessarily useful, there might be non-trivial cases something
like:
class generic_tree():
def insert_member(c hild, parent):
class gui_window_tree (our_tree):
class crypto_algorith ms_tree(our_tre e):
....
(child, parent) = fork_wrapper()
GUIWindows.inse rt_member(child , parent)
EncryptionAlgor ithms.insert_me mber(parent, child)
where flip-flopping names made sense. Though this isn't a
particularly great example, and it might generally be a decent lint
warning.