[swift-evolution] Proposal: newtype feature for creating brand new types from existing types

tuuranton at tutanota.de tuuranton at tutanota.de
Fri Dec 11 14:09:29 CST 2015


//Existing typealias feature.//Foo acts exactly the same way as Double. It's 
the same thing.//Double can be used instead of Foo anywhere.typealias Foo = 
Double
//Proposed newtype feature.//Bar acts exactly the same way as Double and  is 
the same//thing behind the scenes (until we extend it; see below).//Trying to 
use Double instead of Bar will result in a compile-time error.newtype Bar = 
Double
Of course, after creating Bar - a "copy" of the type Double, so to speak - I 
can extend Bar independenly of Double as one would expect.
This would be highly useful.
Your thoughts?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20151211/1cdaec22/attachment.html>


More information about the swift-evolution mailing list