
On Sun, Jun 19, 2011 at 3:41 PM, Raymond Hettinger <raymond.hettinger@gmail.com> wrote:
ISTM, it would be much better if language change proposals came in the form of: "change X makes the following code better and is worth the breaking of code Y and making person Z relearn what the feature does." That would get to essentials while taking the unpersuasive "I was surprised" off the table.
Indeed. If anyone was curious as to why I've been recently trying to steer the discussion back specifically towards Jan's original idea of replacing current (ab)uses of the default argument hack (and nothing more), this is pretty much it. We *know* those use cases exist because there is code in the wild that uses them (including in the standard library). Saying "don't do that" isn't an adequate response as, for anyone that knows about the hack and how it works, the alternatives are far harder to read (in addition to being far more verbose and error prone to write in the first place). Extrapolating to additional functionality that is difficult or impossible in current Python code is sheer speculation that is likely to weigh down any proposal with unnecessary cruft that gets it rejected. What is needed now is one or more volunteers that are willing and able to: 1. Write a PEP that: - distils the core discussion in this thread down into a specific proposal that can be brought up on python-dev - explains *why* the default argument hack is undesirable in general (unintuitive, hard to look up, harmful to introspection, invites errors when calling affected functions) - clearly articulates the uses of the default argument hack that the proposal aims to eliminate (early binding, shared locals, performance) - include real world example of such uses from the standard library (and potentially other code bases) - optionally, also describe the potential "function factories" that could be developed based on the semantics I proposed (see Eric Snow's post for a sketch of how such factories might work once given a template function to work with) 2. Create a reference implementation targeting Python 3.3 (with step 1 being significantly more important at this stage - while the implementation can't be called *easy*, it should be a reasonably straightforward combination of the existing code that handles nonlocal statements and that which handles the calculation and storage of default arguments). I'm not going to do it myself (I already have a couple of open PEPs that I need to make the time to follow up on), but I'm more than happy to provide pointers and advice to someone else that steps up to do so. Cheers, Nick. -- Nick Coghlan | ncoghlan@gmail.com | Brisbane, Australia