[swift-evolution] implementing real (floating point) number comparison tolerance as a compiler directive.

Tino Heth 2th at gmx.de
Wed Mar 2 15:23:38 CST 2016

I hope that I'll finally have the time to write a pitch for "inheritance for structs" this weekend — this looks like another good use case for a "newtype" feature:

struct Length: Double {
	static let tolerance: Double = 0.001

override func ==(a: Length, b: Length) -> Bool {
	return (a - b).abs() < Length.tolerance

Of course, this example leaves many questions, but I hope the principle is clear.


More information about the swift-evolution mailing list