[swift-evolution] Epic: Typesafe calculations
dabrahams at apple.com
Fri Jan 22 11:29:29 CST 2016
on Thu Jan 21 2016, David Waite <swift-evolution at swift.org> wrote:
> So if I understand you correctly, coercion (not
> conversion/representable form) relationships between types, giving you
> the ability to have one type's instance implicitly coerced into an
> instance of another type for the purposes of matching the signature
> needed by a particular method/property/initializer
> So not an Employee-is-a-Person relationship, but more of an
> Int8-is-fully-representable-as-a-Int relationship. In this world,
> [Int] cannot now hold Int8s, but attempting to append an Int8 to such
> an array will cause an Int to automatically be created.
> Also, not implying code sharing, or declaration in at least the
> initial definition of the subtype - I could define a Maybe enum that
> was True,False, or Possibly cases, and a Bool argument could be an
> acceptable substitute.
Those are roughly the lines along which I was thinking.
> One question - could you define then all T to be a subtype/be coerced
> into Optional<T> using language syntax? All Array<T> to
> Array<supertype T>
Maybe; at this point it's all speculative because the feature isn't
More information about the swift-evolution