Data Types

Carbon TypeDescriptionSizenull-ValueMarker
truetruth value true0 bytenull[t]
falsetruth value false0 bytenull[f]
booleanthree-valued logic0+ bytesconst[B]
u8unsigned 8-bit int1 Bnull, 28 - 1[c], [1]
u16unsigned 16-bit int2 Bnull, 216 - 1[d], [2]
u32unsigned 32-bit int4 Bnull, 216 - 1[i], [3]
u64unsigned 64-bit int8 Bnull, 216 - 1[l], [4]
i8signed 8-bit int1 Bnull, -27[C], [5]
i16signed 16-bit int2 Bnull, -215[D], [6]
i32signed 32-bit int4 Bnull, -231[I], [7]
i64signed 64-bit int8 Bnull, -263[L], [8]
float32-bit float4 bytenull, NAN[r], [R]
stringstring of n charsn bytesnull[s]
binarybinary of n bytesn + 2+ bytesnull[b]
custom binarybinary of n bytesn + 3+ bytesnull[x]
nullabsence of data (user-defined)0+ bytenull[n]
undefabsence of data (structure-defined)0 bytenone[N]

Null and Undef

In carbon, there are two way to express absence of data, null and undef. The first one, null, is a mapping of the Json constant null, and is used to express non-present data by the user, e.g., by the Json string "x": null. In contrast, the second one, undef is used to express absence of data that is not only annotated as non-present, but in fact not contained. In no cases, the user can express a undef with its input, but will receive a undef (i.e., "not in list") value whenever the user queries for non-existing data by a dot path expression.

The reason for differencing between null and undef is to enable clear semantic whether a particular dot path expression evaluates to a value that is stored within the record and which is annotated with absence of data by the user (i.e., using a null), or to a value that is not contained in the dataset (i.e., a undef is return).

To ephasis the differences and importance of undef and null, consider the following example

    "x": null

Using a dot path expression asking for the value of the property "x" will result in null since "x" is a valid path that evaluates to a particular value. In contrast, asking for the value of an non-existing property "y" will result in undef since "y" does not exist.