Why not just use a (documentation) comment?

/// The Lifecycle extension:
extension ViewController {
...

-Michael

> Am 16.05.2016 um 18:26 schrieb Brandon Knope via swift-evolution 
> <[email protected]>:
> 
> I like to separate methods into their own logical extensions so similar 
> methods are grouped together. I do this mostly with Cocoa Touch where I like 
> all view life cycle methods to be in the same extension:
> 
> extension ViewController {
>     override func viewDidLoad() {
>     }
>     
>     override func viewWillAppear(animated: Bool) {
>     }
>     
>     override func viewDidDisappear(animated: Bool) {
>     }
> }
> 
> You can document this somewhat by adding a MARK comment:
> 
> // MARK: Lifecylce
> extension ViewController {
>     override func viewDidLoad() {
>     }
>     
>     override func viewWillAppear(animated: Bool) {
>     }
>     
>     override func viewDidDisappear(animated: Bool) {
>     }
> }
> 
> What if we made this more self-documenting by elevating this to a language 
> feature?
> 
> extension ViewController named Lifecycle {
>     override func viewDidLoad() {
>     }
>     
>     override func viewWillAppear(animated: Bool) {
>     }
>     
>     override func viewDidDisappear(animated: Bool) {
>     }
> }
> 
> Other ways:
> extension named Lifecycle ViewController { }
> extension named “View Lifecycle" ViewController { }
> extension ViewController named “Multi word description” { }
> 
> 
> For now, this is purely a documenting feature (i.e. Can’t refer to the 
> extension name dynamically or statically in actual code). I think it plays 
> much more naturally with Swift than requiring this to be in the comments and 
> would work across all IDEs and make it easier for people to find a specific 
> extension as well as making their code more self documenting.
> 
> Any thoughts?
> 
> Thanks,
> Brandon
> 
> 
> 
> _______________________________________________
> swift-evolution mailing list
> [email protected]
> https://lists.swift.org/mailman/listinfo/swift-evolution

_______________________________________________
swift-evolution mailing list
[email protected]
https://lists.swift.org/mailman/listinfo/swift-evolution

Reply via email to