In general, I love this proposal, and look forward to using it to do in-language a variety of things that currently require code generation.
We seem to have lost "witness macros" since the original pitch — the form of attached macro that would allow third-party protocols to get the special treatment afforded to Equatable
, Hashable
, Codable
, etc.
The functionality still seems to be present, by using a combined "conformance" and "member" macro, but I do wish that we still had syntactic parity with the language features:
@SynthesizeDiscriminant
enum MyEnumWithAssociatedValues: Hashable {
case bool(Bool)
case int(Int)
}
vs.
enum MyEnumWithAssociatedValues: Discriminable, Hashable {
case bool(Bool)
case int(Int)
}
just draws attention to the "third-party" nature of the macro, and decouples the macro from the protocol it adds conformance to, since the macro and the protocol live in the same namespace.