It makes some sense for interoperation when living inside .NET or the JVM, but this was a known problem when those systems were designed.
It makes some sense for interoperation when living inside .NET or the JVM, but this was a known problem when those systems were designed.
2. Restricting a language to non-circular data structures will not be popular.
3. Having a nullable and non-nullable version of every pointer or reference type is not usually super popular either.
Phrased differently: nullable types are actually a fairly reasonable compromise from a set of not fully appealing choices.
Also, regarding your third point, IMO the question mark syntax in for example TypeScript and C# is fine.
ftp://ftp.cs.princeton.edu/reports/1989/220.pdf
This was discussed in rust some time ago: https://mail.mozilla.org/pipermail/rust-dev/2013-March/00330...
I'd assume that while Kotlin's String? is equivalent to Optional<String>, Kotlin has no equivalent to Optional<Optional<String>>.
Which, personally, I think I'd prefer Kotlin's approach, because that means you can do `maybeString = "exists"`, which is more readable than `maybeString = Optional::Exists("exists")`
Also, you can still nest them in Kotlin, since you can have a nullable type inside generics.
And you may start needing fancier versions of polymorphism to express things like "this accepts a T=Foo or Optional<Foo>, and returns Bar<T>".
In passing, I remain to be convinced that that x?.length/etc syntax (and equivalents in other variations of Optional) is really a good idea - to me, it feels like an error-prone way of papering over the fact that non-explicit null(aka absent-optional) checks are just too painful to program with. Phrased differently, I see no reason to believe that the sufficiently-common-to-warrant-special-support appropriate handling of null is just to feed it up through as the computation of the computation if it occurs in any part.
There are various possible solutions for circular structures that do not require destroying all static safety with nulls everywhere.
Doing so *nullifies*
pun intended?[0] https://channel9.msdn.com/Blogs/Seth-Juarez/A-Preview-of-C-8...
But essentially they're not solving it: you will get a warning on explicit default-ing of a non-nullable reference, you will get a warning on implicitly initialising/defaulting class fields, but you will not get warnings when doing so for structs or arrays.