[swift-evolution] [Review] SE-0091: Improving operator requirements in protocols

Антон Жилин antonyzhilin at gmail.com
Sat May 28 07:04:54 CDT 2016


> Then, the protocol author is responsible for providing a generic global
trampoline operator that is constrained by the protocol type and delegates
to the static operator on that type:

This feels like an unnatural "hack" to me. This proposal definitely needs
more discussion.

Personally, I'd prefer the following:
* allow `self` internal parameter name in functions
* move `prefix` and `postfix` to external parameter name

Example:

====begin====

protocol SomeProtocol {
    mutating func +(left self: Self, right: Self)
    func ~(prefix self: Self) -> Self
    func -(postfix self: Self) -> Self
}

struct SomeStruct : SomeProtocol {
    func +(left self: SomeStruct, right: SomeStruct)
    func ~(prefix self: Self) -> Self
}

func -(postfix nonSelf: SomeStruct)

====end====


* What is your evaluation of the proposal?
As it stands, -1

* Is the problem being addressed significant enough to warrant a change to
Swift?
Yes.

* Does this proposal fit well with the feel and direction of Swift?
No, I find that it is obscure and brings more "magic" into the language.

* If you have used other languages or libraries with a similar feature, how
do you feel that this proposal compares to those?
No.

* How much effort did you put into your review? A glance, a quick reading,
or an in-depth study?
A quick reading.

- Anton
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160528/a2bf8192/attachment.html>


More information about the swift-evolution mailing list