[swift-evolution] [Review] SE-0090: Remove .self and freely allow type references in expressions

Brent Royal-Gordon brent at architechies.com
Wed May 18 05:43:30 CDT 2016

> 	* What is your evaluation of the proposal?

I am in favor, except that I think we should keep `.self` in the language.

In my years programming, I have on a few occasions found it *very* useful to have an identity method/property automatically available on all instances. For instance, one of my Ruby projects has a model with `last_week`, `last_month`, `last_year`, etc. class methods on it returning subsets of the available models, and I had a screen with a panel summarizing the number of instances in each of these ranges. When I wanted to add an "all time" count, I upgraded to Ruby 2.2 and used its new `itself` method.

To make this actually useful, .self would have to behave like a normal property in all respects—for instance, it would need to have a read-only lens once we support lenses. I don't think this is a tall order, but it *is* something that would need to be done.

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

Yes. It's a pain to write code that talks about types.

> 	* Does this proposal fit well with the feel and direction of Swift?

Yes. We don't normally tolerate "load-bearing duct tape" in the syntax like this.

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

Ruby has first-class, no-muss, no-fuss class objects like this and it's really nice.

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

Quick reading, plus I followed some of the earlier discussions.

Brent Royal-Gordon

More information about the swift-evolution mailing list