[swift-evolution] Epic: Typesafe calculations
Matt Whiteside
mwhiteside.dev at gmail.com
Wed Jan 13 11:53:48 CST 2016
Hey Tino,
> On Jan 13, 2016, at 03:50, Tino Heth <2th at gmx.de> wrote:
> I'm still waiting for someone asking for compile-time execution with a reference to
> https://www.youtube.com/watch?v=UTqZNujQOlA <https://www.youtube.com/watch?v=UTqZNujQOlA>
> (it's such a cool concept — we really should have a use case for it :), and your idea is a variant of this feature.
Yes, what I was suggesting yesterday was at least half inspired by that video, which came up in an earlier thread.
> In theory, this could work without new keywords (when all input is known at compile time, just evaluate),
True, I think you could get a lot of benefit here without new keywords, perhaps with a compiler plugin <https://doc.rust-lang.org/stable/book/compiler-plugins.html> as Sean suggested. But there is one interesting part that seems like it will require a new bit of syntax, which is being able to define new types based on restrictions of some other type's member values. I don’t know if others find that as interesting as I do though :)
> I'm sure that checks at compile-time would not only be useful for calculations:
> NSURL, for example, can be initialized with a string that simply does not represent an URL (therefore, init can return nil). But if the parameter is a string literal, you'll always have the same result at runtime…
Yep, that’s another good example. Here’s to hoping it finds its way into Swift 4 :)
Matt
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160113/2c23a2e3/attachment.html>
More information about the swift-evolution
mailing list