-
Notifications
You must be signed in to change notification settings - Fork 13.6k
'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
'New Philosophical Tutorial' #14017
Conversation
|
||
fn increment(i:int) -> (int) { | ||
i + 1 | ||
} |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
Would be nice to wrap lines. |
y: int | ||
} | ||
|
||
fn draw_polygon(points: ~[Point]) { // Draw the line} |
There was a problem hiding this comment.
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 }
.
I'm excited to see this continue to shape up! |
|
||
# Arguments | ||
|
||
# Conditions |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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"
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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.
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. |
Continued in #14190 |
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.
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'.