News for hackers. Stuff that matters.
Re:Practical Go: Real-world advice for writing maintainable ... by amedvednikov on Thursday February 21, 2019 @01:17PM (#19219113)
https://github.com/vlang-io/V/blob/master/examples/users.v

They are very simple and combine Rust's Option<T> and Result<T>.

Re:Practical Go: Real-world advice for writing maintainable ... by Sholmesy on Thursday February 21, 2019 @02:56PM (#19220020)

  // `http.get()` returns an optional string.
  // V optionals combine the features of Rust's Option<T> and Result<T>.
  // We must unwrap all optionals with `or`, otherwise V will complain.
  s := http.get(API_URL) or {
  // `err` is a reserved variable (not a global) that
  // contains an error message if there is one
  eprintln('Failed to fetch "users.json": $err')
  // `or` blocks must end with `return`, `break`, or `continue`
  return
 }


This looks really handy. Is there somewhere else (outside of V) where I can read about Option types (in the real world, or in theory).
Re:Practical Go: Real-world advice for writing maintainable ... by int_19h on Thursday February 21, 2019 @11:17PM (#19223080)
What's the difference between "break" and "continue" inside an or-block? Or do they apply to the outer enclosing loop if there is one?
Re:Practical Go: Real-world advice for writing maintainable ... by amedvednikov on Friday February 22, 2019 @07:14AM (#19224667)
Yes, just like in Swift.
Re:Practical Go: Real-world advice for writing maintainable ... by int_19h on Friday February 22, 2019 @12:17PM (#19227027)
Then I don't get it - how do you make the or-block exit normally and yield a value, instead of exiting the outer scope one way or another?