> Yes, care needs to be taken about the associativity and commutativity of 
> multiplication of units, but that's not too hard either, it basically amounts 
> to some pattern matching along with symbolic computations respecting 
> algebraic identities (think of it as a compile-time "unit interpreter") and 
> maybe some post-normalization.
I agree: "doing it right" is no rocket science (pun intended ;-) — but I'm 
quite sure it won't be possible unless the macro-system that might be 
introduced with Swift 4 is ready.
But there are possible workarounds for the lack metaprogramming the type 
system, so products with three or four factors should be possible without even 
changing the compiler (it will be ugly, though):
It is easy to define +/- for composed units, but it is a huge amount of code 
that has to be generated for all permutations.

@Tim Hawkins:
Thanks for posting the link — although it reminds me on feeling bad for not 
being in Hamburg right now ;-)
_______________________________________________
swift-evolution mailing list
[email protected]
https://lists.swift.org/mailman/listinfo/swift-evolution

Reply via email to