← SPL reference

Null & library enums

Built-in null, optional-value helpers, and enum tables without new syntax—enums are ordinary hashes of name → number. See also Data types and someProgrammingLanguage/SCOPING.md.

Color key

1. null

The global null is the single absent value (Python None). Many stdlib calls return null on invalid input.

2. Control flow vs logic operators

test.ifTrue(cond) and test.while(cond) run the body only when cond == 1. So null does not take the branch (same as 0).

Logical and / or / not treat null as falsy (like 0), so you can write not / short-circuit style conditions without null accidentally behaving as “true.”

3. Library enums

There is no separate enum type yet: an enum is a hash mapping string names to integers (or other ordinals). Register and bind a name with:

enum.createEnum({ "A": 0, "B": 1 }, Color);

Second argument must be an identifier (variable name), like hash.createHashTable.

4. Example

Repository: examples/features_null_enum.spl (expected output documented in-file).

print.boolean(test.isNull(null));
print.number(null.coalesce(null, 42));
enum.createEnum({ "A": 0, "B": 1 }, Color);
print.string(enum.name(Color, 1));

Reference table filters: null, enum, test (test.isNull), type (type.isNull).