[swift-evolution] [Review] SE-0144: Allow Single Dollar Sign as a Valid Identifier

Jay Abbott jay at abbott.me.uk
Sun Oct 16 12:45:49 CDT 2016


> * What is your evaluation of the proposal?

I am against it.

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

No - if this change were made it would be a regression. The rationale for
removing it in the first place was and remains valid.

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

No, it goes in the opposite direction. $ is not valid as the first
character of a user-defined identifier and therefore should not be a valid
identifier by itself.

Side-note: Personally I think $ as the first character of an identifier
should be reserved for shorthand ways to do other things, in line with how
it is currently used in Swift.
If used consistently, programmers will know they are seeing a language
shortcut. Allowing $ as an identifier would break some of the natural
intuition a programmer is able to use when learning and reading Swift code.

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

The proposal seems purely for the benefit of the Dollar library, which
could work just as well with any other identifier. Code using the dollar
library is reminiscent of some other languages and programming styles. This
isn't really a comment about the proposal itself, more the motivation
behind it.

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

I read the proposal and was perplexed by it, so I looked into the Dollar
library to try and understand the motivation behind the proposal. It is a
clever library with some nice features and tricks, but in many ways it
seems to be designed to enable programmers to write non-Swifty code in
Swift. I can understand the frustration of the author and users of the
library, but its functionality could be provided in a Swifty way using
extensions and generics, and I think if those users embraced this they
would ultimately appreciate the change. If not then they might as well
stick to another language.


On Sun, 16 Oct 2016 at 17:31 Jacob Bandes-Storch via swift-evolution <
swift-evolution at swift.org> wrote:

> Proposal link:
>
>
> https://github.com/apple/swift-evolution/blob/master/proposals/0144-allow-single-dollar-sign-as-valid-identifier.md
>
>
>         * What is your evaluation of the proposal?
>
>
> -1.
>
> The proposal does not actually provide motivation for keeping $ beyond
> "the Dollar library already uses it".
>
> A more Swifty way for a library to introduce these operations would be
> with extensions. Here are some suggestions, based off the first several
> operations described in the library's readme:
>
> $.at → convenience subscript(Index...) for Collection
> $.chunk → convenience function for Sequence
> $.compact → flatMap{$0}
> $.contains → already exists as Sequence.contains
> $.cycle → convenience function for Collection
> $.difference → convenience function on Collection, or just use Set
> operations, or filter
> $.each → exists as Sequence.forEach
> $.every → extension on Sequence
> $.factorial → convenience method or postfix operator for Integer
> $.fetch → convenience function on Collection
> and so on.
>
> It looks like the author's Cent <https://github.com/ankurp/Cent> library
> is already taking this approach.
>
>
>
>         * Is the problem being addressed significant enough to warrant a
> change to Swift?
>
>
> Yes, but the change has already been made: removing $ as a valid
> identifier ;-)
>
>
>
>         * Does this proposal fit well with the feel and direction of Swift?
>
>
> Not really. If anything, IMO, the dollar sign feels more like an operator
> character. (However, it's probably here to stay in identifiers because of
> closure parameters and LLDB variables.)
>
>
>
>         * If you have used other languages or libraries with a similar
> feature, how do you feel that this proposal compares to those?
>
>
> The Dollar library resembles the style of JavaScript libraries such as
> jQuery or Underscore, but that isn't a positive thing in my mind — as
> mentioned above, the Swift way of doing things is different.
>
>
>
>         * How much effort did you put into your review? A glance, a quick
> reading, or an in-depth study?
>
>
> Thorough reading of the proposal; brief glance at the library's readme on
> GitHub.  Lots of time thinking about operator & identifier characters for a
> forthcoming proposal.
>
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20161016/3f9d4f5a/attachment.html>


More information about the swift-evolution mailing list