I'm all with the author with the Ruby love and it looks like Rust managed to implement them in a cleaner syntactic way compared to Ruby. However, that template code was utterly hideous.
fn find_even(vec: &[T]) -> Option {71–80 of 81 posts
I'm all with the author with the Ruby love and it looks like Rust managed to implement them in a cleaner syntactic way compared to Ruby. However, that template code was utterly hideous.
fn find_even(vec: &[T]) -> Option {(As a prerequisite to making its point, the article teaches many intricate details regarding two dynamic languages which even most of their practitioners probably never think about, then dives into more intricate details regarding a language which most of us have probably never even used, let along grokked all the details of. I sense that there's something important here for me to learn, but from where I sit this article is a lot to bite off all at once.)
A tight summary by someone who understands all this would be appreciated by many readers, not just myself.
Only sorta - consider Haskell's indent rule: code which is part of an expression should be indented further than the start of that expression. Generally, this is something you should be doing to make your code readable regardless of the statement termination.
map(lambda t: t ** 2, [1,2,3,4])
or even: [(lambda t: t**2)(x) for x in [1,2,3,4]]Earlier quoted context omitted.
Ruby and CoffeeScript do and their syntax relies heavily on it.
For Ruby at least "heavily" is a big exaggeration. It is significant as a token separator and in cases where inserting a line break makes the expression up to the line break a valid expression in itself, in which case it is treated as one. You pretty much only need to remember to separate tokens where lack of whitespace might create a different vald token, and ensure any expressions that you want to let span more tha…
As an aside, the "power_it" function in Python can also be written as: map(lambda t: t ** 2, [1,2,3,4]) or even: [(lambda t: t**2)(x) for x in [1,2,3,4]]
Why would you have that lambda?
[x**2 for x in range(1, 5)]My kingdom for a TL;DR! (As a prerequisite to making its point, the article teaches many intricate details regarding two dynamic languages which even most of their practitioners probably never think about, then dives into more intricate details regarding a language which most of us have probably never even used, let along grokked all the details of. I sense that there's something important here for me to learn, but f…
A tight summary of all of it would be as long as the article. However, the point about semicolons in Rust is:
1. ; is a separator, not a terminator.
2. a;b separates a and b.
3. a; is a special case which means a;nil(or whatever is the equivalent in Rust)
4. The last expression in a function will be the return value of the function.
5. If the last line in a function is "a", it returns a. If it's "a;", it returns nil(from 3)
My kingdom for a TL;DR! (As a prerequisite to making its point, the article teaches many intricate details regarding two dynamic languages which even most of their practitioners probably never think about, then dives into more intricate details regarding a language which most of us have probably never even used, let along grokked all the details of. I sense that there's something important here for me to learn, but f…
> A tight summary by someone who understands all this would be appreciated by many readers, not just myself. A tight summary of all of it would be as long as the article. However, the point about semicolons in Rust is: 1. ; is a separator, not a terminator. 2. a;b separates a and b. 3. a; is a special case which means a;nil(or whatever is the equivalent in Rust) 4. The last expression in a function will be the return…
My kingdom for a TL;DR! (As a prerequisite to making its point, the article teaches many intricate details regarding two dynamic languages which even most of their practitioners probably never think about, then dives into more intricate details regarding a language which most of us have probably never even used, let along grokked all the details of. I sense that there's something important here for me to learn, but f…
Why all this talk about Python and Ruby? Rust is not really competing with those languages-- it is quite specifically designed as a C++ replacement. They should be comparing themselves against C++, Golang, or D.
The Golang solution would just be a function which returns the next element or nil if there are no more elements. That function might be part of an interface, if you wanted to generalize it across several types. To me, this is a lot simpler than the other stuff that was discussed.
To go back to Rust specifically, rather than having magic semicolons, why not make the "break" statement take a value, which becomes the return value of the block? Despite all the tl;dr there was not much discussion of design alternatives.
Earlier quoted context omitted.
Which keyboard layout is that?
Norwegian. Many european countries use the same placement for semicolon. All the Scandinavian and Baltic countries, Germany and Netherlands to name a few. Russia uses shift+4. Can't imagine how annoying that is.
The Dutch commonly use the US keyboard layout, which makes sense because Dutch and English have the same alphabet.