> On Jan 5, 2016, at 11:16 AM, Thorsten Seitz via swift-evolution 
> <[email protected]> wrote:
> 
> 
>> Am 05.01.2016 um 17:11 schrieb Grzegorz Adam Hankiewicz via swift-evolution 
>> <[email protected]>:
>> 
>> The ideal would be for the compiler to pretend Euros or RefTablePk are 
>> different types, yet use their parent type at the binary level. This needs a 
>> specific syntax to teach the compiler which existing methods/operations are 
>> allowed on the new fake types and which aren’t. These new distinct types 
>> would *borrow* previous implementations.
> 
> What about citing the relevant protocols in the newtype definition? This 
> should include the ability to use my own protocols to which I have made the 
> underlying type conform to by an extension.

This is how my forwarding proposal works.  The newtype syntax I suggested as a 
possible extension looks like this:

newtype Euro = Double forwarding Addable, Subtractable

The keyword could be different, but I think `forwarding` is not bad.  When I 
complete the second draft I think it will make even more sense.  The forwarding 
facility has features to handle non-trivial cases (Self and associated type 
requirements, etc).

> 
> Throwing some syntax into the discussion:
> 
> newtype Euro = Double : Addable, Subtractable
> 
> where I have defined the protocols Addable and Subtractable somewhere and 
> made Double conform to them if all this is not provided by the standard 
> library.
> The implementation of Euro then borrows the implementation of Double for 
> these protocols.
> 
> -Thorsten 
> _______________________________________________
> swift-evolution mailing list
> [email protected]
> https://lists.swift.org/mailman/listinfo/swift-evolution

_______________________________________________
swift-evolution mailing list
[email protected]
https://lists.swift.org/mailman/listinfo/swift-evolution

Reply via email to