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

Joe Groff jgroff at apple.com
Wed May 18 10:46:13 CDT 2016


> On May 18, 2016, at 3:43 AM, Brent Royal-Gordon via swift-evolution <swift-evolution at swift.org> wrote:
> 
> 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.

I thought about this, but { $0 } is already a fairly compact way to express the identity function.

-Joe


More information about the swift-evolution mailing list