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

Edward Connell ewconnell at gmail.com
Sat Mar 11 14:12:24 CST 2017

Observations about difining an object

   - Structs can't inherit and classes shouldn't inherit, final concrete
   types should be flat
   - Protocols need to be adopted by the final concrete type, otherwise
   constraint specializations aren't correctly applied

This creates a really ugly code duplication situation when you have
multiple object variants that adopt the same protocols.

The storage declaration, common initialization, common didSet, etc... for
protocol member variables must be duplicated for every instance.
If I have 20 objects that have the same base set of 15 vars, this turns
into a maintenance/bug nightmare.

I noticed the use of GYB in the swift source code.
I don't want to involve python in anything I do, and I don't want to mess
up my code/build with all that stuff.

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
One piece of code, one tool, one set of bugs.

Has this been considered? Or is there a better way to handle this problem.

Thanks, Ed
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-users/attachments/20170311/cee651ec/attachment.html>

More information about the swift-users mailing list