Question

Why dont we care that parameter names match argument names?
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Because it does not matter.

This is one of the most beautiful features of a programming language.

When a parameter is passed as an argument to some other function the it becomes a "local variable" for that function with the name specified in the definition of the function of that argument.

The only real restriction that we have here is that the data type of the argument and parameter passed must be same. Otherwise you will get an exception.

But if the data type is valid then you may or may not have same name of the parameter passed and the argument defined for the function.

It is like saying that I have a pet name, say 'p' that my family and friend uses to identify me with. But when my parents send me outside to an university they register me by my official name 'o'. So the university authority identifies me by a different name. Same person, two names(references).

The same is the case with functions. They recieve the parameter and now identify it by a different name throughout the execution of the function which hardly makes any difference whether the name is same or different than the name originally given to the parameter passed.

Add a comment
Know the answer?
Add Answer to:
Why don't we care that parameter names match argument names?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT