Skip to content

Commit 5178320

Browse files
committed
PEP 659: address review
1 parent 778d058 commit 5178320

File tree

1 file changed

+36
-36
lines changed

1 file changed

+36
-36
lines changed

pep-0695.rst

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -840,19 +840,19 @@ may be useful when considering future extensions to the Python type system.
840840
C++
841841
---
842842

843-
C++ uses angle brackets in combination with keywords "template" and
844-
"typename" to declare type parameters. It uses angle brackets for
843+
C++ uses angle brackets in combination with keywords ``template`` and
844+
``typename`` to declare type parameters. It uses angle brackets for
845845
specialization.
846846

847847
C++20 introduced the notion of generalized constraints, which can act
848848
like protocols in Python. A collection of constraints can be defined in
849-
a named entity called a "concept".
849+
a named entity called a ``concept``.
850850

851851
Variance is not explicitly specified, but constraints can enforce variance.
852852

853-
A default type argument can be specified using the "=" operator.
853+
A default type argument can be specified using the ``=`` operator.
854854

855-
::
855+
.. code-block:: c++
856856

857857
// Generic class
858858
template <typename>
@@ -897,7 +897,7 @@ Java
897897

898898
Java uses angle brackets to declare type parameters and for specialization.
899899
By default, type parameters are invariant.
900-
The "extends" keyword is used to specify an upper bound. The "super" keyword
900+
The ``extends`` keyword is used to specify an upper bound. The ``super`` keyword
901901
is used to specify a contravariant bound.
902902

903903
Java uses use-site variance. The compiler places limits on which methods and
@@ -906,7 +906,7 @@ not specified explicitly.
906906

907907
Java provides no way to specify a default type argument.
908908

909-
::
909+
.. code-block:: java
910910
911911
// Generic class
912912
public class ClassA<T> {
@@ -923,7 +923,7 @@ C#
923923
--
924924

925925
C# uses angle brackets to declare type parameters and for specialization.
926-
The "where" keyword and a colon is used to specify the bound for a type
926+
The ``where`` keyword and a colon is used to specify the bound for a type
927927
parameter.
928928

929929
C# uses declaration-site variance using the keywords "in" and "out" for
@@ -932,7 +932,7 @@ invariant.
932932

933933
C# provides no way to specify a default type argument.
934934

935-
::
935+
.. code-block:: c#
936936
937937
// Generic class with bounds on type parameters
938938
public class ClassA<S, T>
@@ -955,21 +955,21 @@ TypeScript
955955
----------
956956

957957
TypeScript uses angle brackets to declare type parameters and for
958-
specialization. The "extends" keyword is used to specify a bound. It can be
959-
combined with other type operators such as "keyof".
958+
specialization. The ``extends`` keyword is used to specify a bound. It can be
959+
combined with other type operators such as ``keyof``.
960960

961961
TypeScript uses declaration-site variance. Variance is inferred from
962962
usage, not specified explicitly. TypeScript 4.7 introduced the ability
963-
to specify variance using "in" and "out" keywords. This was added to handle
963+
to specify variance using ``in`` and ``out`` keywords. This was added to handle
964964
extremely complex types where inference of variance was expensive,
965965
yet the maintainers state that is useful for increasing readability.
966966

967-
A default type argument can be specified using the "=" operator.
967+
A default type argument can be specified using the ``=`` operator.
968968

969-
TypeScript supports the "type" keyword to declare a type alias, and this
969+
TypeScript supports the ``type`` keyword to declare a type alias, and this
970970
syntax supports generics.
971971

972-
::
972+
.. code-block:: typescript
973973
974974
// Generic interface
975975
interface InterfaceA<S, T extends SomeInterface1> {
@@ -996,19 +996,19 @@ Scala
996996
-----
997997

998998
In Scala, square brackets are used to declare type parameters. Square
999-
brackets are also used for specialization. The "<:" and ">:" operators
999+
brackets are also used for specialization. The ``<:`` and ``>:`` operators
10001000
are used to specify upper and lower bounds, respectively.
10011001

10021002
Scala uses use-site variance but also allows declaration-site variance
1003-
specification. It uses a "+" or "-" prefix operator for covariance and
1003+
specification. It uses a ``+`` or ``-`` prefix operator for covariance and
10041004
contravariance, respectively.
10051005

10061006
Scala provides no way to specify a default type argument.
10071007

10081008
It does support higher-kinded types (type parameters that accept type
10091009
type parameters).
10101010

1011-
::
1011+
.. code-block:: scala
10121012
10131013
10141014
// Generic class; type parameter has upper bound
@@ -1041,16 +1041,16 @@ Swift
10411041
Swift uses angle brackets to declare type parameters and for specialization.
10421042
The upper bound of a type parameter is specified using a colon.
10431043

1044-
Swift doesn't support generic variance, all type parameters are invariant.
1044+
Swift doesn't support generic variance; all type parameters are invariant.
10451045

10461046
Swift provides no way to specify a default type argument.
10471047

1048-
::
1048+
.. code-block:: swift
10491049
10501050
// Generic class
10511051
class ClassA<T> {
10521052
// Generic method
1053-
func method1<X>(val: T) -> S { }
1053+
func method1<X>(val: T) -> X { }
10541054
}
10551055
10561056
// Type parameter with upper bound constraint
@@ -1065,15 +1065,15 @@ Rust
10651065

10661066
Rust uses angle brackets to declare type parameters and for specialization.
10671067
The upper bound of a type parameter is specified using a colon. Alternatively
1068-
a "where" clause can specify various constraints.
1068+
a ``where`` clause can specify various constraints.
10691069

10701070
Rust does not have traditional object oriented inheritance or variance.
10711071
Subtyping in Rust is very restricted and occurs only due to variance with
10721072
respect to lifetimes.
10731073

1074-
A default type argument can be specified using the "=" operator.
1074+
A default type argument can be specified using the ``=`` operator.
10751075

1076-
::
1076+
.. code-block:: rust
10771077
10781078
// Generic class
10791079
struct StructA<T> {
@@ -1102,16 +1102,16 @@ Kotlin
11021102

11031103
Kotlin uses angle brackets to declare type parameters and for specialization.
11041104
By default, type parameters are invariant. The upper bound of a type is
1105-
specified using a colon. Alternatively a "where" clause can specify various
1106-
constraints.
1105+
specified using a colon.
1106+
Alternatively, a ``where`` clause can specify various constraints.
11071107

11081108
Kotlin supports declaration-site variance where variance of type parameters is
1109-
explicitly declared using "in" and "out" keywords. It also supports use-site
1109+
explicitly declared using ``in`` and ``out`` keywords. It also supports use-site
11101110
variance which limits which methods and members can be used.
11111111

11121112
Kotlin provides no way to specify a default type argument.
11131113

1114-
::
1114+
.. code-block:: kotlin
11151115
11161116
// Generic class
11171117
class ClassA<T>
@@ -1133,10 +1133,10 @@ Julia
11331133
-----
11341134

11351135
Julia uses curly braces to declare type parameters and for specialization.
1136-
The "<:" operator can be used within a "where" clause to declare
1136+
The ``<:`` operator can be used within a ``where`` clause to declare
11371137
upper and lower bounds on a type.
11381138

1139-
::
1139+
.. code-block:: julia
11401140
11411141
// Generic struct; type parameter with upper and lower bounds
11421142
struct StructA{T} where Int <: T <: Number
@@ -1153,16 +1153,16 @@ Dart
11531153
-----
11541154

11551155
Dart uses angle brackets to declare type parameters and for specialization.
1156-
The upper bound of a type is specified using the "extends" keyword. By default,
1157-
type parameters are covariant.
1156+
The upper bound of a type is specified using the ``extends`` keyword.
1157+
By default, type parameters are covariant.
11581158

1159-
Dart supports declaration-site variance where variance of type parameters is
1160-
explicitly declared using "in", "out" and "inout" keywords. It does not support
1161-
use-site variance.
1159+
Dart supports declaration-site variance, where variance of type parameters is
1160+
explicitly declared using ``in``, ``out`` and ``inout`` keywords.
1161+
It does not support use-site variance.
11621162

11631163
Dart provides no way to specify a default type argument.
11641164

1165-
::
1165+
.. code-block:: dart
11661166
11671167
// Generic class
11681168
class ClassA<T> { }

0 commit comments

Comments
 (0)