|
|
|
|
|
by CraigJPerry
2015 days ago
|
|
There’s another approach - where null takes on contextual meaning. List<Integer> f = null;
f.add(1);
This is clearly a NullPointerException in Java but in a language with Nil punning, f is automatically a list containing 1. (conj nil 1)
;;=> (1)
|
|
That said, for me personally, nil punning is uncomfortably close to the kind of weak typing (like in traditional JS) that can be catastrophic in large code bases.
However, I’ve never worked with a large code base in a Lisp - whereas I have with various statically-typed functional and non-functional languages - and I find static typing, particularly Option types, very valuable.