Skip to content

Clarify unit expressions section of reference #24738

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

Merged
merged 1 commit into from
Jun 16, 2015
Merged

Clarify unit expressions section of reference #24738

merged 1 commit into from
Jun 16, 2015

Conversation

joliv
Copy link
Contributor

@joliv joliv commented Apr 23, 2015

The "unit value" is a value of the "unit type," not the "unit value type." Regardless of correctness, this straight syntax is easier to grok.

Part of #16676

Sorry if something's off here, it's my first pull request to rust!

@rust-highfive
Copy link
Contributor

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @steveklabnik (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. The way Github handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see CONTRIBUTING.md for more information.

@bluss
Copy link
Member

bluss commented Apr 23, 2015

You should update it to say that () is an empty tuple; we don't call it a separate unit type anymore.

@joliv
Copy link
Contributor Author

joliv commented Apr 23, 2015

Huh, guess I'm pretty behind that development! Going to need to update more than just that section by the looks of it if that's the case, but I'll start with just 7.2.4. Can I just append another commit, or should I squash the old one? New to the rust-lang repo.

@joliv
Copy link
Contributor Author

joliv commented Apr 23, 2015

Actually, it looks like a little more than some editing to that section will be needing. Maybe even removing that section altogether? I probably ought to rescind this PR.

@steveklabnik
Copy link
Member

Yeah, this was removed.

You can add a new commit, but before merging, we'll want to squash it down.

@pnkfelix
Copy link
Member

Wait, have we officially stopped referring to () as "unit," like when we talk about it in English?

While it is perhaps interesting to look at it as a trivial empty tuple, I am not sure if there is all that much pedagogical value there. . . the phrase "unit type" has a lot of meaning in terms of the conventions about where such types are used (which match up well with how they are used in Rust...)

@steveklabnik
Copy link
Member

Wait, have we officially stopped referring to () as "unit," like when we talk about it in English?

I'm not sure, to be honest. But it's not at type anymore.

@bluss
Copy link
Member

bluss commented Apr 26, 2015

I agree with you pnkfelix. () is still a type, but it's classified among the tuple types. And to keep the nickname unit type seems useful. It ought to have a good name since it's the default expression and function return value.

@bors
Copy link
Collaborator

bors commented May 12, 2015

☔ The latest upstream changes (presumably #25320) made this pull request unmergeable. Please resolve the merge conflicts.

@steveklabnik
Copy link
Member

Okay, so anyway....

I agree with @pnkfelix here. It's nice to keep the nickname, even though they're the same thing. However, since it's a nickname, I'm not sure that this still deserves its own section.

@joliv are you interested in fixing up this PR?

@joliv joliv closed this Jun 15, 2015
@joliv
Copy link
Contributor Author

joliv commented Jun 15, 2015

Yeah, I can do it based off graue's comments on #25244. As for that close, github closes the pull request if the branch has no differing commits for a moment, as it did when I deleted my old commit via a force push. Hopefully it will reopen when the new commits are pushed.

@joliv
Copy link
Contributor Author

joliv commented Jun 15, 2015

Okay, there we go!

@joliv joliv reopened this Jun 15, 2015
@@ -3316,6 +3316,9 @@ assert!(b != "world");
assert!(p.0 == 10);
```

For historical reasons and convenience, the tuple type with no elements (`()`)
is often called "unit" or "the unit type."
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you

  1. use single instead of double curlies
  2. put the period outside of the single curlie
  3. use actual curlie quotes rather than ' (there are some in this file if you want to copy/paste them.

@steveklabnik
Copy link
Member

Awesome, thanks! Just a few nits about the curlies, and also, can you put 'Fixes #25244' in the commit text, so when this gets merged, it closes the associated issue. Thanks!

@joliv
Copy link
Contributor Author

joliv commented Jun 16, 2015

Yeah, I forgot to match the style of the rest of the ref—had my Strunk & White blinders on, I guess. It should be up to snuff now!

@steveklabnik
Copy link
Member

It's all good! Thanks :)

@steveklabnik
Copy link
Member

@bors: r+ rollup

@bors
Copy link
Collaborator

bors commented Jun 16, 2015

📌 Commit b87056f has been approved by steveklabnik

@bors
Copy link
Collaborator

bors commented Jun 16, 2015

⌛ Testing commit b87056f with merge c4d064f...

@bors
Copy link
Collaborator

bors commented Jun 16, 2015

💔 Test failed - auto-mac-64-nopt-t

@alexcrichton
Copy link
Member

@bors: retry

On Tue, Jun 16, 2015 at 8:18 AM, bors notifications@github.com wrote:

[image: 💔] Test failed - auto-mac-64-nopt-t
http://buildbot.rust-lang.org/builders/auto-mac-64-nopt-t/builds/5400


Reply to this email directly or view it on GitHub
#24738 (comment).

@bors
Copy link
Collaborator

bors commented Jun 16, 2015

⌛ Testing commit b87056f with merge 1035645...

bors added a commit that referenced this pull request Jun 16, 2015
The "unit value" is a value of the "unit type," not the "unit value type." Regardless of correctness, this straight syntax is easier to grok.

Part of #16676

Sorry if something's off here, it's my first pull request to rust!
@bors bors merged commit b87056f into rust-lang:master Jun 16, 2015
@joliv joliv deleted the patch-2 branch June 18, 2015 21:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants