[swift-evolution] Pre-proposal: Safer Decimal Calculations

Step C schristopher at bignerdranch.com
Sat Mar 19 18:24:47 CDT 2016

Do you have a link to that research? I'd be very interested. 

> On Mar 19, 2016, at 11:46 AM, Tino Heth via swift-evolution <swift-evolution at swift.org> wrote:
>> Can't quite see where "Inheritance for structs / "newtype"-feature"
>> enables this, however. Care to explain?
> It's not required, but unless you want to implement a completely new numeric type (like fractions), it is tedious to declare all operations and conversions that are useful or required:
> struct CustomDouble {
> 	let value: Double
> }
> func == (a: CustomDouble, b: CustomDouble) -> Bool {
> 	return abs(a.value - b.value) < 0.01
> }
> This type can handle the comparison, but actually, you don't want a struct that contains a double, but that is a double (and inherits all abilities of this type).
> Greg Titus already did some research and made the observation that such simple container-types have no memory or performance penalty, but as a developer, you have to write many stupid functions that do nothing but forwarding operations on x to x.value…
> Tino
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160319/61bc013a/attachment.html>

More information about the swift-evolution mailing list