[swift-evolution] Epic: Typesafe calculations

Thorsten Seitz tseitz42 at icloud.com
Tue Jan 12 16:00:22 CST 2016


> Am 12.01.2016 um 22:29 schrieb Tino Heth <2th at gmx.de>:
> 
>> 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>
> Wait, I miss a "*" in the signature ;-) — but yes, this is one major goal.

Oh, indeed, I forgot the "*“ :-)
But it’s proof of the usefulness of the strong typing proposed that you could deduce what operator I meant, isn’t it? ;-)

> I'm just not sure if it's clever to actually write down the whole example (vector math looks scary to some people — maybe it's better to simply say "you can do it" ;-)

Writing down stuff explicitly is important because only then one can see whether something really works out as desired.
So, yeah, we should have lots of concrete examples in the proposal.

> The tiny example should only illustrate how the parameters can be used inside the type. It might be a good idea to show how it's possible to do solve some real world

Yeah, but that same code would have been possible without the proposal (except that the parameters would have been let properties of the instance).

> problems like applying a force vector to an object with a given impulse… (if I remember right, there's a thread started by a teacher who uses playgrounds in class — I guess I'll ask him for support).

Good idea!

-Thorsten


More information about the swift-evolution mailing list