scala-library-next icon indicating copy to clipboard operation
scala-library-next copied to clipboard

Unboxed Option

Open NthPortal opened this issue 4 years ago • 6 comments

It keeps coming up, and we still don't have it. Even if we have to have Option and UOption in the stdlib at the same time, I think it's probably better than people using null all the time over concerns about the overhead cost of Option. As has been noted by @sjrd a lot of times, null cannot be equivalent to Option due to its lack of parametricity (I think?).

And Seb has already written the implementation too!

We can also give it easy (implicit?) conversions to and from "normal" Options.

NthPortal avatar Dec 03 '20 05:12 NthPortal

For reference, this is my implementation: https://github.com/sjrd/scala-unboxed-option

sjrd avatar Dec 03 '20 07:12 sjrd

oops, sorry for not linking it

NthPortal avatar Dec 03 '20 07:12 NthPortal

@sjrd I assume you're okay with licensing your implementation to Lightbend/EPFL under Apache 2?

NthPortal avatar Dec 03 '20 16:12 NthPortal

What would be the migration story? Do we want to eventually keep both options? @sjrd do you have download stats for your implementation?

julienrf avatar Dec 03 '20 16:12 julienrf

Sure, I can relicense it under Apache 2.

Download stats are not useful: the library has 3 methods or so, so it's not even usable as is. Nobody would actually use as such. I wrote it as a proof of concept.

sjrd avatar Dec 03 '20 17:12 sjrd

motivated in part by discussions on https://contributors.scala-lang.org/t/elvis-operator-for-explicit-nulls/4639

NthPortal avatar Dec 04 '20 09:12 NthPortal