PEP 622: Don't use "ADT" for "algebraic data types"

ADT already means Abstract Data Types (a different concept).
This commit is contained in:
Guido van Rossum 2020-06-24 18:14:29 -07:00
parent 33788eb974
commit a39035a22e
1 changed files with 5 additions and 5 deletions

View File

@ -781,14 +781,14 @@ every class is matchable and therefore is subject to the checks specified
above.
Sealed classes as ADTs
----------------------
Sealed classes as algebraic data types
--------------------------------------
Quite often it is desirable to apply exhaustiveness to a set of classes without
defining ad-hoc union types, which is itself fragile if a class is missing in
the union definition. A design pattern where a group of record-like classes is
combined into a union is popular in other languages that support pattern
matching and is known under a name of algebraic data types [2]_ or ADTs.
matching and is known under a name of algebraic data types [2]_.
We propose to add a special decorator class ``@sealed`` to the ``typing``
module [6]_, that will have no effect at runtime, but will indicate to static
@ -797,8 +797,8 @@ be defined in the same module as the base class.
The idea is that since all subclasses are known, the type checker can treat
the sealed base class as a union of all its subclasses. Together with
dataclasses this allows a clean and safe support of ADTs in Python. Consider
this example::
dataclasses this allows a clean and safe support of algebraic data types
in Python. Consider this example::
from dataclasses import dataclass
from typing import sealed