Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Name the ~= (pattern matching?) operator when introducing it #304

Closed
swift-ci opened this issue Mar 8, 2016 · 7 comments · Fixed by #306
Closed

Name the ~= (pattern matching?) operator when introducing it #304

swift-ci opened this issue Mar 8, 2016 · 7 comments · Fixed by #306
Labels
Content issue A problem in with the book's prose, code, or figures Good first issue Work that's well-suited for new contributors

Comments

@swift-ci
Copy link

swift-ci commented Mar 8, 2016

Previous ID SR-896
Radar None
Original Reporter douglashill (JIRA User)
Type Improvement
Additional Detail from JIRA
Votes 1
Component/s Standard Library
Labels Improvement, Documentation
Assignee None
Priority Medium

md5: fccac19dc8668e07b859568b36ae3644

Issue Description:

Reading through the Swift book in iBooks, the ~= is mentioned but not named. There are numerous advantages to having a clear name:

  • We can vocalise internally while reading and writing code. Many of us need to think using language: it is how we structure our thoughts.
  • We can vocalise while speaking (rather than writing) to other people about Swift.
  • Provides guidance on expected behaviours when overloading the operator.
  • Names are easier to search for. Most search engines (including Google and Jira) seem to ignore ~=.

I am sorry if I am missing the name somewhere; it's hard to search for.

https://docs.swift.org/swift-book/documentation/the-swift-programming-language/patterns

@swift-ci
Copy link
Author

swift-ci commented Mar 8, 2016

Comment by Douglas Hill (JIRA)

Best suggestion I’ve header is ‘matches’.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@Azoy Azoy closed this as completed May 9, 2024
@douglashill
Copy link

What was the resolution for this?

@Azoy
Copy link
Member

Azoy commented May 9, 2024

Are you suggesting just a name for documentation purposes or something along the lines of renaming the ~= operator in source to something else? We can't do the latter anymore, and if you're suggesting the former then I'm not sure that's a standard library issue. I can reopen this if so, I'll just remove the standard library label.

@AnthonyLatsis
Copy link

We appear to have always referred to it as the pattern-matching operator in the compiler. The standard library does so too:

https://github.com/apple/swift/blob/c09fa4ef927c98a2c7d0393534f8e1e4e039cfbd/stdlib/public/core/Policy.swift#L352-L357

The book just says "operator" still. @Azoy Do you mind transferring this to swift-book?

@AnthonyLatsis AnthonyLatsis reopened this May 10, 2024
@Azoy Azoy transferred this issue from apple/swift May 13, 2024
@Azoy
Copy link
Member

Azoy commented May 13, 2024

@AnthonyLatsis done

@amartini51 amartini51 changed the title [SR-896] ~= operator should have a name Name the ~= (pattern match?) operator when introducing it May 13, 2024
@amartini51 amartini51 added the Content issue A problem in with the book's prose, code, or figures label May 13, 2024
@amartini51 amartini51 changed the title Name the ~= (pattern match?) operator when introducing it Name the ~= (pattern matching?) operator when introducing it May 13, 2024
@amartini51
Copy link
Collaborator

Calling it the "pattern-matching operator" seems reasonable to me.

@amartini51 amartini51 added the Good first issue Work that's well-suited for new contributors label May 15, 2024
@amartini51
Copy link
Collaborator

Confirmed with Brian (who wrote the original version of this circa 2014) — there doesn't seem to be any reason to avoid naming this operator.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Content issue A problem in with the book's prose, code, or figures Good first issue Work that's well-suited for new contributors
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants