@@ -754,6 +754,30 @@ were less clear. Also, this syntax did not interact well with class and
754
754
function decorators, which are common in Python. Only one other popular
755
755
programming language, C++, uses this approach.
756
756
757
+ We likewise considered prefix forms that looked like decorators (e.g.,
758
+ ``@using(S, T) ``). This idea was rejected because such forms would be confused
759
+ with regular decorators, and they would not compose well with existing
760
+ decorators. Furthermore, decorators are logically executed after the statement
761
+ they are decorating, so it would be confusing for them to introduce symbols
762
+ (type parameters) that are visible within the "decorated" statement, which is
763
+ logically executed before the decorator itself.
764
+
765
+
766
+ Angle Brackets
767
+ --------------
768
+ Many languages that support generics make use of angle brackets. (Refer to
769
+ the table at the end of Appendix A for a summary.) We explored the use of
770
+ angle brackets for type parameter declarations in Python, but we ultimately
771
+ rejected it for two reasons. First, angle brackets are not considered
772
+ "paired" by the Python scanner, so end-of-line characters between a ``< ``
773
+ and ``> `` token are retained. That means any line breaks within a list of
774
+ type parameters would require the use of unsightly and cumbersome ``\ `` escape
775
+ sequences. Second, Python has already established the use of square brackets
776
+ for explicit specialization of a generic type (e.g., ``list[int] ``). We
777
+ concluded that it would be inconsistent and confusing to use angle brackets
778
+ for generic declarations but square brackets for explicit specialization. All
779
+ other languages that we surveyed were consistent in this regard.
780
+
757
781
758
782
Bounds Syntax
759
783
-------------
@@ -1043,7 +1067,7 @@ Rust uses declaration-site variance, and variance of type parameters is
1043
1067
typically inferred from their usage. In cases where a type parameter is not
1044
1068
used within a type, variance can be specified explicitly.
1045
1069
1046
- Rust provides no way to specify a default type argument .
1070
+ A default type argument can be specified using the "=" operator .
1047
1071
1048
1072
::
1049
1073
@@ -1149,7 +1173,7 @@ Summary
1149
1173
+------------+----------+---------+--------+----------+-----------+-----------+
1150
1174
| Swift | <> | T: X | | | decl | inferred |
1151
1175
+------------+----------+---------+--------+----------+-----------+-----------+
1152
- | Rust | <> | T: X, | | | decl | inferred, |
1176
+ | Rust | <> | T: X, | | = | decl | inferred, |
1153
1177
| | | where | | | | explicit |
1154
1178
+------------+----------+---------+--------+----------+-----------+-----------+
1155
1179
| Kotlin | <> | T: X | | | use, decl | inferred |
0 commit comments