On 22.09.2016 7:46, Russ Bishop via swift-evolution wrote:
On Sep 20, 2016, at 4:34 PM, Dave Abrahams via swift-evolution
<[email protected]> wrote:
on Tue Sep 20 2016, Karl <razielim-AT-gmail.com> wrote:
I think the best way is to prefix the member name with the protocol,
e.g:
protocol MyProto { var aVariable : Int func aFunction() } class
MyClass : MyProto { var MyProto.aVariable : Int func
MyProto.aFunction() { … } }
...
CC-ing Dave A, to understand better if this fits with the vision of
protocols
I generally agree with Doug. The canonical way to indicate “this
method/property/type implements a requirement of protocol P” should
be to define the entity in an extension that also adds conformance to
P. If that's inadequate indication in some way we should find a way
to enhance it. I wouldn't mind the notation above, but only as a
fallback, not a reuquirement.
-- -Dave _______________________________________________
Indeed this is exactly how C# handles Interfaces (protocols). The
Can C#'s interface(protocol) have default implementations for its
requirements like in Swift?
default is the exact same way Swift works - by matching names. If there
is a collision you specify Protocol.memberName. Its simple and in the
years I was writing C# code it was flexible enough to cover most
reasonable scenarios, without adding a bunch of boilerplate.
Russ
_______________________________________________ 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