Mathew Elman writes:

 > I believe this is a rebirth of a request that has come up many
 > times before, which is to have something like javascript's
 > `undefined` where it means "use the default value" if passed to a
 > function that has a default value or "value not provided" (slightly
 > different to "None").
[...]
 > "undefined" would either have to be an alias for "None" everywhere
 > _except_ function signatures, or be only allowed in function
 > signatures and have special handling.

Either would be a significant complication in Python semantics,
though.  And I don't really see how the latter works:

notdefined = None
def foo(x=undefined):                # here
    notdefined = x
    return wrapped_function(x)       # there
foo()
print(notdefined)

To get this "use the default" functionality from #here to #there,
either the above has to allow you to capture the object representing
undefined but you're not allowed to use the name "undefined" for it
(very un-Pythonic), or there has to be some horrifying magic, maybe
macro-like, that turns the name "x" into a name that isn't there.

 > It opens up a can of worms in javascript but has its uses.

If you're phishing, I guess worms are useful.  *shudder*

Wisecracks aside, I'm not sure I want to read code designed so that
'undefined' is genuinely useful.  I'd need to see real code that uses
it, plus the translation to Python, plus some argument why it has to
be that way, before I'd be willing to go higher than -1 on this
complication.
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/QOX623SJC65TB5U4TIZRC7EW6T2K2XT2/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to