Skip to content

'New Philosophical Tutorial' #14017

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

Closed
wants to merge 15 commits into from
Closed

Conversation

plaindocs
Copy link

Hi Guys,

Some work in progress on the new tutorial. Complete direction change from the previous PR - we're now aiming at a 'Rust way of doing things' much more than 'syntax basics'.


fn increment(i:int) -> (int) {
i + 1
}
Copy link
Member

Choose a reason for hiding this comment

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

Do we want to declare this inside of main? At least explicitly explaining that this is possible would be good.

Copy link
Author

Choose a reason for hiding this comment

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

Good point. As you can see - not much work on this one - not sure if it will even survive the rethink.

@adrientetar
Copy link
Contributor

Would be nice to wrap lines.

y: int
}

fn draw_polygon(points: ~[Point]) { // Draw the line}
Copy link
Member

Choose a reason for hiding this comment

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

probably should be a space between line and }.

@steveklabnik
Copy link
Member

I'm excited to see this continue to shape up!


# Arguments

# Conditions
Copy link
Member

Choose a reason for hiding this comment

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

Should we consider using a different word here, given that the word "Conditions" had a prior meaning in the code base that I assume is very different than what is going to be presented in this section? (If you search for "conditions" in the github repository you will see what I mean.) I suppose my concern is if people come to the chat room asking about something they read in this section, and old-timer community members say "we don't have conditions anymore", yielding confusion.

Copy link
Member

Choose a reason for hiding this comment

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

What's a "condition" in this context?


Rust is a compiled programming language with a focus on type safety, memory safety, concurrency and performance. It has a sophisticated memory model that encourages efficient data structures and safe concurrency patterns, forbidding invalid memory accesses that would otherwise cause segmentation faults.

This brief introduction to Rust focuses on Rust's design choices, strengths and 'philosophy'. You should already be already familiar with programming concepts, in particular pointers, and a programming language from the C-family. The [syntax guide][syntax] is a reference to the nuts and bolts of the language, essentials such as [variables][guide-var], [functions][guide-fn], [structs][guide-struct] etc.
Copy link
Contributor

Choose a reason for hiding this comment

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

"You should s/already// be already familiar"

Copy link
Member

Choose a reason for hiding this comment

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

I'd actually remove the other one.


<!-- FIXME: not really happy with this, we're already talking about allocating memory, so the ~ is forced -->

In Rust, the `~` operator allocates memory, so `~expr` allocates space on the heap, evaluates `expr` and stores the result on the heap. For example, `p=~Point { x: 1, y: 2 }`. `p` is not of type `Point` but of type `~Point`, the `~` indicates that it is a pointer to a heap allocation.
Copy link
Contributor

Choose a reason for hiding this comment

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

We should probably refer to box instead of the ~ sigil here.

@plaindocs
Copy link
Author

Cheers for the feedback guys - helpful stuff. I think this last commit fixes all the minor issues you've mentioned. I'll work with @nikomatsakis to reword some of the vague memory claims and the Point/Line issue.

@brson brson mentioned this pull request May 14, 2014
@brson
Copy link
Contributor

brson commented May 14, 2014

Continued in #14190

@brson brson closed this May 14, 2014
brson pushed a commit to brson/rust that referenced this pull request May 14, 2014
bors added a commit to rust-lang-ci/rust that referenced this pull request Feb 13, 2023
internal: remove `TypeWalk`

Because less code is better!

`hir_ty::TypeWalk` is only used in analysis-stats and its usage can be replaced by checking `TypeFlags` (which is precomputed upon `TyKind` interning so it should make analysis-stats a bit faster, though it was really negligible in my local environment).

We should just use chalk's `TypeVisitor` or `TypeFolder` instead even if we come to need it again.
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