Skip to content

Note naming convention of lists (xs, ys, ...) #15410

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
Aug 11, 2014
Merged

Note naming convention of lists (xs, ys, ...) #15410

merged 1 commit into from
Aug 11, 2014

Conversation

LemmingAvalanche
Copy link
Contributor

People reading the tutorial may not be familiar with the convention of naming lists, vectors and the like as xs, ys, etc. Without some explanation of the reasoning behind it, it might come off as just throwaway non-descriptive names. Languages like Haskell gets flak from using short, non-descriptive names, while in reality, there are clear conventions and reasons for using certain terse variable names.

This is just a proposed explanation of this convention, as I've interpreted it - I assumed that the convention came from a language like Haskell, so I tailored it according to that. So beware that I might have misjudged how it is used in the Rust language, or at least how it is used in the Rust tutorial.

> *Note:* Names like `xs` and `ys` are due to a naming
> convention of collection-like data structures
> (like our `List`) in which they are given names
> appended with 's' to signify plurality, ie
Copy link
Member

Choose a reason for hiding this comment

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

Should probably be 'i.e.' (or just write the "the data structure stores multiple elements" in brackets).

@alexcrichton
Copy link
Member

cc @steveklabnik

@steveklabnik
Copy link
Member

I like this idea, but I don't know what our actual convention is here. I personally like xs.

@alexcrichton
Copy link
Member

I don't think we really have a naming convention around lists right now, they're sorta just called what's "most appropriate" I believe. That being said, this seems fine to include. Can you squash the commits together?

@LemmingAvalanche
Copy link
Contributor Author

@alexcrichton Since I chose to edit the document through the online editor instead of forking, committing locally and then sending a pull request, I don't seem to be able to squash the commits - my fork has not preserved my commits, only the commits at the time of the fork. I guess I would have to fork again, make the appropriate changes locally, and then open a new pull request. Would that be OK?

@steveklabnik
Copy link
Member

They're on your patch-1 branch, you can pull it down, squash, and push back up (with force) just like any other branch.

People reading the tutorial may not be familiar with the convention of naming lists, vectors and the like as xs, ys, etc. Without some explanation of the reasoning behind it, it might come off as just throwaway non-descriptive names. Languages like Haskell gets flak from using short, non-descriptive names, while in reality, there are clear conventions and reasons for using certain terse variable names.

I assumed that the convention came from a language like Haskell, so I
tailored the explanation according to that.
@LemmingAvalanche
Copy link
Contributor Author

@steveklabnik Thanks for the tip! @alexcrichton I've squashed the commits together now.

@alexcrichton
Copy link
Member

Thanks @LemmingAvalanche!

bors added a commit that referenced this pull request Aug 11, 2014
People reading the tutorial may not be familiar with the convention of naming lists, vectors and the like as xs, ys, etc. Without some explanation of the reasoning behind it, it might come off as just throwaway non-descriptive names. Languages like Haskell gets flak from using short, non-descriptive names, while in reality, there are clear conventions and reasons for using certain terse variable names. 

This is just a proposed explanation of this convention, as I've interpreted it - I assumed that the convention came from a language like Haskell, so I tailored it according to that. So beware that I might have misjudged how it is used in the Rust language, or at least how it is used in the Rust tutorial.
@bors bors closed this Aug 11, 2014
@bors bors merged commit 14e245b into rust-lang:master Aug 11, 2014
@LemmingAvalanche LemmingAvalanche deleted the patch-1 branch August 11, 2014 08:44
bors added a commit to rust-lang-ci/rust that referenced this pull request Aug 21, 2023
…eykril

internal : rewrite DeMorgan assist

fixes rust-lang#15239 , rust-lang#15240 . This PR is a rewrite of the DeMorgan assist that essentially rids of all the string manipulation and modifies syntax trees to apply demorgan on a binary expr. The main reason for the rewrite is that I wanted to use `Expr::needs_parens_in` method to see if the expr on which the assist is applied would still need the parens it had once the parent expression's operator had equal precedence with that of the expression. I used `.clone_(subtree|for_update)` left and right and probably more than I should have, so I would also be happy to hear how I could have prevented redundant cloning.
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.

5 participants