Hacker News new | past | comments | ask | show | jobs | submit login

Different feature, I'm talking about the optional initialization section added to conditionals. It allows moving declarations to the point of use like for statements. I've also met people who think it's now the appropriate place to declare all block scope variables, which is horrifying.



It's horrifying but maybe also intriguing?

Has shades of the OCaml/StandardML "let ... " scope:

StandardML:

  let
    val a = 1
    val b = 2
  in
    a + b
  end
It's nice for making it clear that the scope of the assignment is restricted to this lexical scope, though there are other ways to do this in C/C++.

I work in Rust these days so haven't had a chance to use much of this, but I wonder if this has some nice RAII type use patterns? I may now go explore.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: