Imho this topic was much better than that other one ;-) — and I just realised
that of metaprogramming build on top of reflection wasn't discussed in its own
thread yet…
I fear "constexpr" is already burned, because people associate it with things
like calculating Fibonacci numbers at compile time (which is kind of cool, but
doesn't have much merit for most of us).
Right now, there is SE-185, which allows to synthesise Equatable and Hashable.
To do so, nearly 1500 lines of C++ are needed, and even if we assume that two
thirds are comments and whitespace, it's still a big piece of code that could
only be written by someone with deep knowledge about C++ and the Swift compiler.
Compile time metaprogramming could do the same, but in probably less than
twenty lines of Swift that could be written rather easily by anyone who knows
the language…
So to update my list of things that might be added, there are also some points
that are already there and whose implementation could have been simplified
drastically:
> - Forwarding of protocol conformance (Kotlin, for example, has this: When a
> member conforms to a protocol, you don't have to write a bunch of methods
> that just say "let my member do this")
> - init with reduced boilerplate
> - Subtyping for non-class types, including a "newtype" option
> - Property behaviours
- Equatable, Hashabable
- Encoding/Decoding
I still wonder that virtually no one else seems to be thrilled about the power
of the idea… @gor.f.gyolchanyan would you like join an attempt to raise the
attention?
- Tino
_______________________________________________
swift-evolution mailing list
[email protected]
https://lists.swift.org/mailman/listinfo/swift-evolution