+1; if existed, i would use this feature instead of 'override' 90% of the time.
It also allows the superclass to define where to call 'super.method()' - at top or bottom of the method; although im not sure whether or not that will complicate method body of superclass with additional syntax. > On Nov 17, 2016, at 12:30 AM, Mustafa Sabur via swift-evolution > <[email protected]> wrote: > > Hallo, > > I have a very simple suggestion. And I’m not very sure then it haven’t been > discussed already, so I’m sorry if that is the case. > I would like to see the ability to just add code to base methods instead of > overriding it and calling supers method. So basically an extension for > methods. > > Example: > > Now: > override func viewDidLoad() { > super.viewDidLoad() > // Your code > } > > Suggestion: > addinto func viewDidLoad() { > // Your code > } > > My reasons: > 1. Its very verbose about your intentions, which fits into Swift style. The > thing you actually want is not overriding but appending. > 2. You cannot make the mistake of forgetting to call the supers method. > 3. It open ways to introducing ‘semi-final’ methods, which cannot be override > but you still can append to it. > This to make sure your API implementation will always be executed . I’m > thinking about a keyword like extendable to specify that you can only add to > it. > 4. Less code. > > I can’t think of any cons... Thought I can imagine that the benefits are > quite small and maybe not worth the effort. > I would like to read some thoughts about this. Thank you! > > Kind regards, > Mustafa Sabur > > > > _______________________________________________ > 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
