Rust has a few syntactic ways to accomplish the same thing, though. I think match expressions are used for the equivalent of conditionals that carry the condition value into the body of the expression, and all blocks return the result of the last statement, so you can do things like:

let mut x;
while { x = foo(); x } {
bar(x);
}

I don't know if that's idiomatic Rust (and I wrote it on a phone and didn't check to be sure it compiles), but it does more or less solve the problem of assignment in a control flow condition.

On April 27, 2018 12:58:16 AM UTC, Steven D'Aprano <steve@pearwood.info> wrote:
On Thu, Apr 26, 2018 at 09:36:48AM -0700, Mike Miller wrote:

However, there were two good questions in this message which I haven't seen
addressed yet:

- How are other modern languages solving this issue?
- How does this new construct intersect with typing functionality?

What counts as a modern language? Less than five years old? Less than
fifty years old? Are Javascript, Ruby and R modern? They all support
assignment as expressions.

I think Koitlin, Rust and Go prohibit assignment as expressions.

Swift assignment evaluates as Void (equivalent to None in Python, I
guess), so you can use assignment in an expression but it returns
nothing and only operates by side-effect.

As far as type hints go, I think that if you need explicit type hints in
the middle of an expression, it's a bad idea and you ought to pull it
out as a separate statement. That applies regardless of whether that
expression involves binding or not.