As part of Swift for TensorFlow we have been working towards designing a set of protocols that more closely resemble mathematical concepts and can, for example, be used for conveniently implementing numerical optimizers. In trying to integrate our changes with the standard library we bumped into an issue related to
Numeric. We have already designed a few protocols (e.g.,
PointwiseMultiplicative) for which we support automatic conformance derivation for aggregate types (e.g., structs containing tensors). We want to also support
Numeric derivations for such aggregate structures and the current issue is that the
Comparable constraint on
Magnitude is causing some issues as it's not straightforward what the semantics should be. To that end we have two main questions:
- Would removing the
Magnitudebe acceptable if we can make a good case for it? It seems to be used in very few places across the standard library and so removing it should not result in big changes. However, we are not sure what implications it would have for ABI stability.
- Similarly, would it be acceptable to completely remove
Magnitudeand the related
Numeric? It also seems to be used in very few places across the standard library, but we have the same concerns regarding this.
Any feedback/discussion around this would be greatly appreciated!