Saturday, July 19, 2014

Building assert() in Swift

Apple:

When designing Swift we made a key decision to do away with the C preprocessor, eliminating bugs and making code much easier to understand. This is a big win for developers, but it also means Swift needs to implement some old features in new ways. Most of these features are obvious (importing modules, conditional compilation), but perhaps the most interesting one is how Swift supports macros like assert().

@auto_closure is great, but I still wish for the power of actual macros.

Update (2015-02-11): Part 2 introduces __FILE__ and __LINE__. Swift does not have a way of capturing the expression as a string, among other limitations from not having macros.

Comments RSS · Twitter

Leave a Comment