[swift-evolution] [swift-evolution-announce] [Review] SE-0144: Allow Single Dollar Sign as a Valid Identifier
brent at architechies.com
Wed Oct 19 18:23:15 CDT 2016
> On Oct 14, 2016, at 12:59 PM, Chris Lattner <clattner at apple.com> wrote:
> * What is your evaluation of the proposal?
I know this is cutting against the grain, but I'm in favor.
I don't think the Dollar library is a good design, but I think there *are* good designs which could use an extremely short, distinctive identifier like `$`. These would be cases where there is a single, specific object, operation, or type which is absolutely central to the problem domain. jQuery is a good example of this: it is used in browsers, where DOM manipulation is such a big part of what you're doing that an extremely shorthanded syntax is appropriate. Other examples might include parsing or generating strings. In general, anything where a Swift file is effectively "embedded" or acting as a "plugin" might benefit from `$`.
Certainly that is not most Swift code, but this is a harmless change when you don't need it, and a helpful change when you do. And certainly code using it may be a little sloppy unless there's preprocessing involved, but sometimes a sloppy solution is the most expressive one.
> * Is the problem being addressed significant enough to warrant a change to Swift?
Maybe. It certainly is possible to design around it by switching to a single identifier character, but few of those stand out in the same way `$` does.
> * Does this proposal fit well with the feel and direction of Swift?
I think it does. Swift disfavors boilerplate, and the places I imagine `$` ought to be used are those where a longer name would introduce unacceptable amounts of boilerplate.
> * If you have used other languages or libraries with a similar feature, how do you feel that this proposal compares to those?
> * How much effort did you put into your review? A glance, a quick reading, or an in-depth study?
Not much more than a glance.
More information about the swift-evolution