> On May 18, 2016, at 3:43 AM, Brent Royal-Gordon via swift-evolution
> <[email protected]> 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
_______________________________________________
swift-evolution mailing list
[email protected]
https://lists.swift.org/mailman/listinfo/swift-evolution