+8
-7
lines changedFilter options
+8
-7
lines changed Original file line number Diff line number Diff line change
@@ -613,13 +613,14 @@ those ideas are recorded here.
613
613
614
614
The ``None``-aware syntax applies to attribute and index access, so it seems
615
615
natural to ask if it should also apply to function invocation syntax. It might
616
-
be written as ``foo?()``, where ``foo`` is only called if it is not None. This
617
-
idea was quickly rejected, for several reasons.
618
-
619
-
First, no other mainstream language has such syntax. Second, Python evaluates
620
-
arguments to a function before it looks up the function itself, so
621
-
``foo?(bar())`` would still call ``bar()`` even if ``foo`` is ``None``. This
622
-
behaviour is unexpected for a so-called "short-circuiting" operator.
616
+
be written as ``foo?()``, where ``foo`` is only called if it is not None.
617
+
618
+
This has been rejected on the basis of the proposed operators being intended
619
+
to aid traversal of partially populated hierarchical data structures, *not*
620
+
for traversal of arbitrary class hierarchies. This is reflected in the fact
621
+
that none of the other mainstream languages that already offer this syntax
622
+
have found it worthwhile to support a similar syntax for optional function
623
+
invocations.
623
624
624
625
``?`` Unary Postfix Operator
625
626
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
You can’t perform that action at this time.
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