Revisiting the idea of meta-programming in Swift

You're right that there is little to no enthusiasm here for template meta-programming as done in C++. However, there have been several attempts to discuss other meta-programming approaches, here's one from the language creator himself and the long forum thread that ensued four years ago.

More recently, there was a pitch by an Apple engineer that expressed interest in going in that direction again, though that first pitch was narrowly constrained to avoid the issue of compile-time evaluation for now.

I agree with you that Swift is lacking in this regard and while there seems to be community interest in adding meta-programming, we don't want to repeat the mistakes of past attempts in other languages. The new constexpr approach in C++ is a tacit admission that their prior compile-time approaches were a mistake.

I think you will have to wait till the follow-on pitches mentioned in that last link are proposed, to help push the language in this direction.

1 Like