Changing the way `unsafeNull` works

The Dotty project is doing fewer big user-visible changes these days, and focusing more on fixing bugs and making everything consistent. But once in a while, a significant change still pops up.

So for those following along at home, I call your attention to this PR that just got opened. It’s still a draft, so it’s way, way early, but worth paying attention to. It’s a major change to the long-standing project of making Scala more null-safe, by making nulls more explicit.

The complication there is, how do you work with external APIs that might produce nulls? How much ceremony is involved in that?

The previous design was a concept of UncheckedNull, an odd little type that allowed you to live dangerously with those values. Apparently that’s proven problematic, so this PR switches to a new model: using a new language import that declares this scope as an “unsafe null” zone, where you can do dangerous things.

It seems like a sensible approach; hopefully it will work well. In general, I consider null-safety one of the lovelier features in the Dotty project, so I’d like it to get nice and solid soon…

Lifelong programmer and software architect, specializing in online social tools and (nowadays) Scala. Architect of Querki (“leading the small data revolution”).

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store