Menu

📰
0

Reddit - Please wait for verification

Java News/Tech/Discussion/etc. No programming help, no learning Java·/u/Fenrurrr·3 days ago
#9ahuSOZe
Reading 0:00
15s threshold

I've been reading up on Project Valhalla and the null-restricted types work. As I understand it, the proposed syntax is: Point! p; // cannot be null Point? p; // explicitly nullable Point p; // unspecified (legacy default) My question: instead of forcing me to sprinkle ! on basically every field and parameter, why couldn't we declare a directive at the top of a file (or package) that flips the default? Something conceptually like: // hypothetical: this whole file is non-null by default non-null; class Cursor { Point position; // implicitly non-null Point? lastHover; // opt back IN to nullable with ? } So: With the directive → everything is ! by default, and you write ? for the rare nullable cases. Without the directive → you keep today's behavior and write ! explicitly when you want non-null. In most codebases non-null is overwhelmingly the common case, so this would massively cut the noise.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.

Read More