News for hackers. Stuff that matters.
Re:Option and null in dynamic languages by dschiptsov on Tuesday December 09, 2014 @05:58AM (#8722108)
OK, lets make it long and explicit.

Asserting that an obscure, optional either-of type is some fundamental concept every single language has been overlooked is, of course, nonsense.

The fundamental concept is notion of "nothingness", "emptiness", what other languages call NIL. Without this a language would be very clumsy, like Math without zero.

The notion of empty vs. non-empty is captured in so-called "either-of" types. The most obvious example is '() - an empty list. Conceptually, it is a List, but it is also indicator of "emptiness", of "nothing inside".

A List is an "either-of type" itself, so it does not require any additional specialize type to capture the notion that it could be empty - it already has it.

Another example is so-called "C-strings". There is notion of end-of-string marker, so a string could be viewed as a list instead of an array of characters. In this case (of a list) we don't have define anything special for "empty string" - the notion of "just end-of-string marker" is good-enough.

Again. This Just/Nothing type in Haskell is nothing special or fundamental. It is an optional, non-essential construct.

There are no comments on this comment yet.