Swift: Allow developers to tag functions with a category name for organizational purposes

Originator:mail
Number:rdar://17253557 Date Originated:2014-06-10
Status:Open Resolved:
Product:Developer Tools Product Version:
Classification:Feature Request Reproducible:
 
Summary:
Smalltalk has the notion of categories. This is not the same as Objective-C categories, but a "tag" that you give a method. The Smalltalk Browser shows the methods of a class organized by category. 

Examples of categories: initialization, handling actions, printing, state restoration, etc. Even inside a class that is well-designed so that it has only a single responsibility, it can be useful to group the various private methods by purpose.

Swift currently has no #pragma mark, which Obj-C developers have used to visually organize their source code files into separate sections. 

Letting developers attach a category name to functions allows them to organize their code semantically (rather than just in text), and gives the compiler access to this meta information.

Xcode can then group the functions by category in its jump bar menu, giving the developer a quick overview of how their code is organized.

Other languages have the ability to attach annotations with arbitrary meta data to methods etc. Maybe Swift will allow such annotations at some point, which could be used for this purpose.

Steps to Reproduce:
-

Expected Results:
-

Actual Results:
-

Version:
Xcode 6 beta 1

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!