Swift: No Macros, No Compromises
Using Swift with Cocoa and Objective-C (via Andrew Bancroft, emphasis added):
Complex macros are used in C and Objective-C but have no counterpart in Swift. Complex macros are macros that do not define constants, including parenthesized, function-like macros. You use complex macros in C and Objective-C to avoid type-checking constraints or to avoid retyping large amounts of boilerplate code. However, macros can make debugging and refactoring difficult. In Swift, you can use functions and generics to achieve the same results without any compromises. Therefore, the complex macros that are in C and Objective-C source files are not made available to your Swift code.
This is the sort of thing that really bothers me about Apple and Swift. I think Apple oversold how ready it was this summer, but it’s understandable that the compiler is buggy and that debugging and performance are problematic. And there is certainly a case to be made (though I would disagree) that macros should not be in the language or should not be used in most cases. But the emphasized sentence is so laughably, obviously false that one wonders why Apple bothered to include it. The results are not the same, and there most certainly are compromises. There’s a lot that you just can’t do in Swift because it lacks macros. Do Swift’s designers really believe this? Does the author not know what he or she is talking about? Or is Apple being deliberately misleading in order to “sell” the language? Either way, this sort of writing does not belong in technical documentation, and it’s especially jarring considering how Microsoft has used those same words.
Update (2015-01-31): Christoffer Lernö:
Given how many warts we could’ve fixed in Swift with even rudimentary macros, the statement in the docs become even more ludicrous.