Arc Forumnew | comments | leaders | submitlogin
Statements vs Expressions: Iteration protocols in Python, Ruby and Rust (pocoo.org)
3 points by akkartik 4595 days ago | 4 comments


1 point by Pauan 4594 days ago | link

This actually makes a tremendous amount of sense if you consider ";" to be a statement separator rather than a statement terminator. For instance, in C, JavaScript, etc. you can have an "empty statement" which is just a semicolon:

  ;
This means that in the following block of code...

  foo;
  bar;
  qux;
The semicolon at the end isn't terminating the "qux" statement, it's creating a new empty statement.

---

Slightly relevant: I much much much prefer Ruby over Python, quirks and all.

-----

1 point by rocketnia 4594 days ago | link

"The semicolon at the end isn't terminating the "qux" statement, it's creating a new empty statement."

I don't understand that interpretation. If the last semicolon is its own statement, where's the semicolon that separates it from the previous statement?

You might be thinking of Pascal, where semicolons separate statements but there's a zero-character empty statement. It seems like Pascal vs. C always comes up when semicolons are involved, and the semicolon business is one of the first differences highlighted at http://en.wikipedia.org/wiki/Comparison_of_Pascal_and_C.

-----

1 point by Pauan 4594 days ago | link

The last semicolon is the separator. The "thing" to the right that it's separating is an implicit empty statement. So yes, I am exactly describing Pascal. And that's the difference between a language where ";" is a separator and where it's a terminator.

-----

1 point by kinleyd 4594 days ago | link

Ruby greatly over Python for me too.

-----