What language links are not null by default?

Out of interest, I want to read about languages ​​that are designed this way. Haskell is alone, right?

I'm talking about languages ​​that do this, but also have compiler support to catch issues like if it were null, then you should have the appropriate cases, processing to compile, etc.

Also this is just a concept, what about functional programming? It also exists in some OO languages?

+5
source share
6 answers

To answer the first part of your question, you are right that Haskell does not have a special "null" value, which can be of any type.

, . , Maybe, :

safeDiv :: Float -> Float -> Maybe Float

safeDiv a b
    | b == 0    = Nothing
    | otherwise = Just (a / b)

, safeDiv Float Maybe Float. Nothing, b , Just (a / b).

, , Nothing , - .

Haskell , . Maybe , , Prelude ( ) . , head, , , , , , Maybe.

+2

ML- ( Haskell ) , SML F # ( null F # .NET- .NET). Scala null, , JVM, , .

+2

, Nullable - .

, . , null/nil, ; ?

, , , (, ), , ( ).

, null/nil-object ( OO) , , asString(), , "" ?

+1

, , - , () ++ () Spe#.

Spe# API ( JML, AsmL Eiffel), # , , .
— Spe# Microsoft Research

, , ( ). ! (, object! string![]!).

++, , - , ++ ; , , , . ++ , (*) ( 0), ++ (&), - . - AFAIK, . , , . , .

, , , . #. , , Jon Skeet , . , NotNull<T> , - , Spe#.

+1

++ . ++- (- Qt, ), API, , . , "*" "- > ", , "" - , -, , , .

Haskell , , . ++ , , , . ( : , , , : - , , , assert. , , , .)

(, , , , . , ( , ) , nullness. , .)

+1

, Haskell null , , FFI , .

0

All Articles