scala / scala-library-next

backwards-binary-compatible Scala standard library additions
Apache License 2.0
67 stars 17 forks source link

Unboxed Option #50

Open NthPortal opened 3 years ago

NthPortal commented 3 years ago

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.

sjrd commented 3 years ago

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

NthPortal commented 3 years ago

oops, sorry for not linking it

NthPortal commented 3 years ago

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

julienrf commented 3 years ago

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

sjrd commented 3 years ago

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.

NthPortal commented 3 years ago

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