[swift-evolution] Making `.self` After `Type` Optional

Keith Smiley keithbsmiley at gmail.com
Tue Mar 15 01:07:30 CDT 2016


I personally don't mind the trailing `.self` but it does seem strange that you
need that, or not, based on the number of parameters. I definitely think it
would be nice to unify this one way or the other.

Another interesting consideration I ran into just today is trying to use `self`
as a `#selector` in Swift 2.2. Swift happily converts:

```
Selector("self")
```

To:

```
#selector(NSObjectProtocol.self)
```

In some cases. But because of `.self` referencing the type, this doesn't do what
you'd expect. Which is an interesting edge case.

--
Keith Smiley

On 03/14, Charles Constant via swift-evolution wrote:
> +1 for junking the .self requirement
>
> On Wed, Mar 9, 2016 at 11:14 PM, David Hart via swift-evolution <
> swift-evolution at swift.org> wrote:
>
> > I strongly agree for the removal of .self. I remember it being a great
> > source of confusion when I first learned Swift.
> >
> >
> I had the same experience. It was very disorienting.
>
> Now that Dave and Joe have explained its origin as a safety feature, it
> makes sense. The problem is that there's no way to convey that to the
> end-user, so it seems like it has some deeper meaning. Then you start
> second-guessing yourself if there's an error in your code, etc.
>
> Nice to see that this might be fixed. Evolution is making me happier and
> happier lately :)

> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution



More information about the swift-evolution mailing list