News for hackers. Stuff that matters.
Re:Java Is Unsound: The Industry Perspective by jpfed on Tuesday January 24, 2017 @03:14PM (#13475033)
I didn't imply it was desired or wasn't possible...? Another reply to my comment clarified that Optional also only applies to value types, which makes it analogous to Nullable. There's no reason to port it (as opposed to any other implementation of an Optional type) over.

What is really necessary is an equivalent for reference types.

struct Maybe<T> where T : class {

  private bool _isInitialized;
  private T _data;

  public Maybe(T data) {
    _isInitialized = (data != null);
    _data = data;
  }

  // ...etc
}
Re:Java Is Unsound: The Industry Perspective by platz on Tuesday January 24, 2017 @03:23PM (#13475106)
> Optional also only applies to value types

no - Java's Optional applies to reference types.

Re:Java Is Unsound: The Industry Perspective by dsp1234 on Tuesday January 24, 2017 @03:36PM (#13475226)
Yes, I was misreading the documentation. The Optional class itself is to be considered a value type, and reference equality on Optional objects shouldn't be done.