473,394 Members | 1,852 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

tool to check whether formal and actual parameters have similar names

Hi,

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)

plot (1, y) # not ok, but this is ok: plot(x=1, y)

We can take this further:

avg = x1 + x2
plot( avg, y) # ok since avg gets name x from x1, x2

Does this make any sense, even in a heuristic sense?
Does such a tool already exist? Would it be useful?

Amir

Jul 18 '05 #1
2 1788
"Amir Michail" <am******@gmail.com> wrote in message news:<cf********@odak26.prod.google.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.width, square.height)
for column in range(8):
for row in range(8):
move_pawn_to(column, 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(string_to_send): # probably a log.write method in
real life
....
write_log(server.error_message)
write_log(user.username)

def wait_for_connection(socket):
....
wait_for_connection(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(child, parent):
class gui_window_tree(our_tree):
class crypto_algorithms_tree(our_tree):
....
(child, parent) = fork_wrapper()
GUIWindows.insert_member(child, parent)
EncryptionAlgorithms.insert_member(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.
Jul 18 '05 #2

"Amir Michail" <am******@gmail.com> wrote in message
news:cf********@odak26.prod.google.com...
def plot(x,y): ...

plot( x1, y1 ) # ok

plot( y1, x1 ) # not ok,
Reversing args reflects plot about 45 degree line, which is a quite
legitimate thing to do if that is what you want to do. Perhaps original
coder got plot 'backwards' and editor want to reverse it without changes
name throughout code.
but this is ok: plot (x=y1, y=x1)
If *you* want to force yourself to jump thru hoops like this, go ahead, but
don't expect anyone else to follow ;-)
Does this make any sense, even in a heuristic sense?


Not really. I name things like age, weight, height, cholesteral_level with
their proper names or abbreviations thereof. Your idea strikes me as an
interesting brainstorm that on second thought would best be left behind.

Terry J. Reedy

Jul 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

50
by: Edward K. Ream | last post by:
I would like to say a few (actually more than a few) words here about some recent discoveries I have made concerning the interaction of Leo and Python. If you don't want to hear an inventor enthuse...
26
by: JGH | last post by:
How can I check if a key is defined in an associative array? var users = new array(); users = "Joe Blow"; users = "John Doe"; users = "Jane Doe"; function isUser (userID) { if (?????)
1
by: r.shimmin | last post by:
There exist a number of related informal markup languages whose design philosophy is to use terse, easily human-entered and human-read tags, that are intended to be converted by software into some...
2
by: Ben | last post by:
My current project requires me to create part of a form that is created on the fly. The project consists a list of entries to an event. The name and address and such is easy. The design is detup so...
9
by: Sandy | last post by:
Hello - I need either a cheap tool or code & DB that calculates, eg. within 50-mile radius of a zip code. Anyone have any suggestions? -- Sandy
7
by: ab3331 | last post by:
I need a tool that acts like a browser, but instead of actually rendering a page, it explains in English exactly what rules it's interpreting. This would make it simple to see which rules are...
4
by: Anastasios Hatzis | last post by:
I'm looking for a pattern where different client implementations can use the same commands of some fictive tool ("foo") by accessing some kind of API. Actually I have the need for such pattern for...
26
by: webrod | last post by:
Hi, I have some php pages with a lot of HTML code. I am looking for a HTML validator tool (like TIDY). TIDY is not good enough with PHP tags (it removes a lot of php code). Do you have any...
5
by: =?Utf-8?B?RGF2aWQgTGV2aW5l?= | last post by:
This is really more of a "why was C# designed this way?" type of question. Hope this is the write forum for this question. Given the following : class Base1 { public int i; } struct Base2...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.