[swift-users] It seems like we really need an #include preprocessor directive?

Jens Alfke jens at mooseyard.com
Sun Mar 12 00:08:01 CST 2017


> On Mar 11, 2017, at 12:12 PM, Edward Connell via swift-users <swift-users at swift.org> wrote:
> 
> It seems that an easy workaround would be an #include statement. 
> The boiler plate can be put in a separate file and included wherever it's needed. 

IMHO this seems like a surefire ‘design smell’ — if you have a use case where you find yourself wanting a preprocessor to eliminate lots of redundant lines in your source code, then either your code or the language you’re using have serious problems.

(I see absolutely nothing wrong with inheritance, and it solves exactly this sort of problem. Yes, structs can’t inherit, but they can contain a common struct as a member, which is quite similar and addresses this issue.)

—Jens
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-users/attachments/20170311/23b7c05c/attachment.html>


More information about the swift-users mailing list