On 10/08/2013 04:33 PM, Larry Hastings wrote: > > I've contributed a new PEP to humanity. I include the RST for your reading pleasure below, but you can also read it > online here: > > http://www.python.org/dev/peps/pep-0457/ I like it! :) Feedback below... > > > ============================== > Notes For A Future Implementor > ============================== > [snip] > > The obvious solution: add a new singleton constant to Python > that is passed in when a parameter is not mapped to an argument. > I propose that the value be called called ``undefined``, ^ called is doubled -------------/ > and be a singleton of a special class called ``Undefined``. > If a positional-only parameter did not receive an argument > when called, its value would be set to ``undefined``. To stick with current practice: --> type(Ellipsis) <type 'ellipsis'> --> type(None) <type 'NoneType'> --> type(NotImplemented) <type 'NotImplementedType'> The instance should be Undefined and its class either undefined or UndefinedType. > But this raises a further problem. How do can we tell the > difference between "this positional-only parameter did not > receive an argument" and "the caller passed in ``undefined`` > for this parameter"? > > It'd be nice to make it illegal to pass ``undefined`` in > as an argument to a function--to, say, raise an exception. > But that would slow Python down, and the "consenting adults" > rule appears applicable here. So making it illegal should > probably be strongly discouraged but not outright prevented. Agreed. > However, it should be allowed (and encouraged) for user > functions to specify ``undefined`` as a default value for > parameters. Also agreed. > ==================== > Unresolved Questions > ==================== > > There are three types of parameters in Python: > > 1. positional-only parameters, > 2. positional-or-keyword parameters, and > 3. keyword-only parameters. > > Python allows functions to have both 2 and 3. And some > builtins (e.g. range) have both 1 and 3. Does it make > sense to have functions that have both 1 and 2? Or > all of the above? Rather than try to think up the cases where it makes sense, let's just support all three. Thanks for writing this up, Larry! -- ~Ethan~
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4