
On 2020-04-19 07:23, Richard Damon wrote:
There is also the issue that if we are building a function that might be used with another function, we will have an incentive to name our keyword parameters that there is a reasonable chance would also be passed to that other function with the same keyword name, even if that might not be the most descriptive name.
Many of the function keyword parameters I deal with are data property names; so it makes sense that the data has the same name throughout the codebase. The incentive to align our variable names would be a good thing. Consider pymysql, and the connect parameters
connect( host=host, port=port, user=username, passwd=password )
With the proposal, right, or wrong, there would be an incentive for me to write the caller to use pymysql property names, and the callers of that caller to also use the same property names. This will spread until the application has a standard name for username and password: There is less guessing about the property names. I have done this in ES6 code, and it looks nice. Maybe aligning variable names with function keyword parameteres is an anti-pattern, but I have not seen it. I reviewed my code: of 20,360 keyword arguments, 804 (4%) are have the x=x format. I do not know if this is enough to justify such a proposal, but I would suggest that is a minimum: Currently there is no incentive to have identical names for identical things through a call chain; an incentive will only increase the use of this pattern.