> Le 17 mars 2016 à 06:50, Haravikk via swift-evolution > <[email protected]> a écrit : > > >> On 17 Mar 2016, at 09:27, Tino Heth via swift-evolution >> <[email protected] <mailto:[email protected]>> wrote: >> Have a look at http://www.martinfowler.com/bliki/FluentInterface.html >> <http://www.martinfowler.com/bliki/FluentInterface.html> for a good reason >> to keep "results" discardable. > > Ack, hit send before quoting this part to come back to it. > > I assume your point here is that having to add @discardableResult (or > whatever) will lead to fluent interfaces becoming prone to the same mistakes > that non-fluent interfaces currently have with @warn_unused_result. > > Perhaps we could add some kind of attribute to the type itself to allow for > selection between the two behaviours? > > For example, we could use a different attribute in the style of: > > @unusedResult(ignore) > @unusedResult(warn)
If we go with something like this, we may want to also have a: @unusedResult(critical) Which generate error for unused result, and a warning when assigning the result to _. This could be useful for function which return allocated resources, which is a return code that should never be ignored even explicitly. Dany
_______________________________________________ swift-evolution mailing list [email protected] https://lists.swift.org/mailman/listinfo/swift-evolution
