[Pitch] Member macros that know what conformances are missing

This would have a number of effects that I can think of:

  1. Stored properties would be scattered across extensions, so it wouldn't be clear what "the storage" of a type actually is without tools
  2. Similarly, the implicit memberwise initializer involves looking across all of the extensions
  3. Classes would get many more overridable methods---it's everything in the file. This would pessimize existing code (larger virtual tables, more dispatch through them)
  4. Protocols get more requirements, where any member of a protocol extension is both requirement and its own default implementation (?)

Personally, I like that the type definition provides the whole "shape" of the type in a single place: its fields, requirements, superclass, required initializers, overridable members, etc. It's what the type "is". Everything provided in extensions is "extra" on top of that core shape, giving it what the type "does". And while it would make some things easier if an extension could extend that core shape, I think the loss of the ability to look in a single place to find a type's "shape" would make code overall harder to understand.

Doug

4 Likes