[Python-ideas] Null coalescing operator

Sven R. Kunze srkunze at mail.de
Sat Sep 10 13:40:22 EDT 2016


On 10.09.2016 19:14, Random832 wrote:
> As I remember the discussion, I thought he'd more or less conceded on
> the use of ? but there was disagreement on how to implement it that
> never got resolved. Concerns like, you can't have a?.b return None
> because then a?.b() isn't callable, unless you want to use a?.b?() for
> this case, or some people wanted to have "a?" [where a is None] return a
> magic object whose attribute/call/getitem would give no error, but that
> would have to keep returning itself and never actually return None for
> chained operators.
That appeared to be one solution to make the ?-syntax class useful.

But in the end, there were too many possibilities (operator?, nomad 
objects?, syntax expansion?, something else?), issues with all those "?" 
all over the place, hiding errors this way (which was the most serious 
one), and uncertainty about the overall benefit of this syntax compared 
to better designs like "how to not use None in the first place" didn't 
lead to a result so far.


Let's see those can be resolved.


Sven


More information about the Python-ideas mailing list