> On 17 Mar 2016, at 09:27, Tino Heth via swift-evolution 
> <[email protected]> wrote:
> Have a look at 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)

Add this to a function and it affects that specifically, add it to a type and 
it affects all methods of that type (unless they have their own attribute 
overriding it). So for a fluent interface I could do:

        @unusedResult(ignore)
        protocol MyFluentType {
                func something() -> Self
                func somethignElse() -> Self

                @unusedResult(warn)
                func notAFluentMethod() -> Self
        }

If we do get return type attributes then the return type form could become 
@unused(ignore) to make it a bit shorter?
_______________________________________________
swift-evolution mailing list
[email protected]
https://lists.swift.org/mailman/listinfo/swift-evolution

Reply via email to