Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

You did mean shadowing then. But your example is deceptive, that C-like assignment syntax doesn't exist in Reason, much less in OCaml. The real Reason syntax makes the shadowing much clearer:

  let a = 10;
  {
    let a = 20;
  }
  print(a);
And even more clear in OCaml:

  let a = 10 in
  begin
    let a = 20 in
    ()
  end;
  print a
BTW you should also close the page on Rust then, which also has OCaml-like variable shadowing (and many other languages use very similar forms of shadowing, such as local variables shadowing object fields in Java/C#).


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

Search: