Comment

Comment by ajnin

Looks good, finally a language-supported way to remove thousands of unnecessary Exceptions and null-checks. But the nullness-narrowing automatic conversions feel wrong. From the proposal :

  String? id(String! arg) { return arg; }
  
  String s = null;
  Object! o1 = s; // NPE
  Object o2 = id(s); // NPE
  Object o3 = (String!) s; // NPE
Surely at least the two first cases should yield a compiler error. The last case you're explicit so it's borderline but I'd rather see something like :

  String s = ...
  if (s != null) {
    # Here the compiler knows that the effective type is String!
    String! ss = s; # OK
  }
Like this no possibility of error.
parent ajnin 2 years ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton