[swift-evolution] Epic: Typesafe calculations

Thorsten Seitz tseitz42 at icloud.com
Tue Jan 12 11:45:30 CST 2016


Hi Tino,

the real advantage is missing from the proposal :-)

With the proposal it should be possible to write

func<T, rows1, cols1, rows2, cols2 where cols1 == rows2>(lhs: Matrix<T, rows1, cols1>, rhs: Matrix<T, rows2, cols2>) -> Matrix<T, rows1, cols2>
{ … }


The example in the proposal just uses the static parameters for runtime checks which is no advantage over using init parameters.

-Thorsten


> Am 12.01.2016 um 15:22 schrieb Tino Heth via swift-evolution <swift-evolution at swift.org>:
> 
> Hi there!
> 
> I hope there's still some interest in the topic (or in the cartwheels-video Matt promised ;-) and just finished the draft for a first proposal.
> Instead of trying to turn typealias into some sort of newtype, which leaves a lot more questions open as I thought originally, I started with "compile-time parameters":
> The name of the feature can be discussed (as well as its details), but it would not only add typesafety to matrix, vector, tensor and other entities, but also offer a simple way to handle computations with physical quantities (three of those should be sufficient in most cases, so the idea mentioned by Thorsten should work fine).
> 
> I still haven't taken the time to take a detailed look at boost units, but I would be glad if someone with practical experience could contribute to the proposal — the same is true for all other parts, as I'd happily turn the document into a joint paper (I'm not sure, but maybe it could even become the first multi-author submission :)
> 
> To make this easier, I created a wiki-page; this should be editable without forking a repository (I haven't figured out if a can give write permissions to everyone, so it might be necessary to click somewhere to request permissions).
> The URL is
> https://github.com/SwiftTypesafeCalculations/Home/wiki/Compile-time-parameters
> 
> Happy collaboration!
> Tino
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution



More information about the swift-evolution mailing list