@@ -512,19 +512,18 @@ defaults.
512512Rationale
513513=========
514514
515- Class builders make the class-transforming nature of dataclasses, enums, and
516- typing constructs visible at the start of the statement. This is easier to
517- read and teach than a decorator or base class that changes class construction
518- after the reader has already parsed the statement as an ordinary class.
519-
520- The builder protocol deliberately reuses class-body machinery instead of
521- introducing a general macro or block system. This keeps the feature close to
522- existing class semantics while still allowing builders to return non-class
523- objects when appropriate.
524-
525- Only bare names are accepted as builders. This keeps the syntax compact and
526- avoids ambiguous statement prefixes such as ``pkg.builder C: ``. Users can
527- bind a local name when they want to use a builder imported from another module.
515+ Python has various constructs that are somewhat like classes, but behave
516+ subtly (or not so subtly!) differently. This PEP proposes a generic, flexible
517+ mechanism for defining such constructs.
518+
519+ An alternative could be to add specific syntax for some or all of the constructs
520+ for which this PEP proposes to use class builders. For example, ``protocol `` could
521+ be made a soft keyword, allowing protocols to be written as proposed in this PEP,
522+ but without an import and without a more powerful new language feature.
523+
524+ However, this would unduly privilege the standard library. There are use
525+ cases in third-party frameworks that could be helped by builder syntax, including
526+ alternative dataclass-like frameworks, ORMs, or DSLs.
528527
529528
530529Backwards Compatibility
0 commit comments