remove nil/null: absence is an error, empty object is the only no-value

- delete the nil type; catscript has no nil and no null
- add the empty object (Object with no members), exposed as the global
  'empty'; it is a shared immutable singleton
- 'nil' is no longer a keyword: it is an undefined global, which raises
- undefined global -> error (consistent with a missing attribute)
- only 'false' is falsy (numbers/objects are truthy); booleans kept
- OP_NIL -> OP_EMPTY; compiler, VM, stdlib, toml, ffi, generator, file,
  list, selector, value all migrated
- rename the table type to Object
- std/ front-end and examples/tests migrated to 'empty'
- 84/84 tests
This commit is contained in:
Minus committed 2026-11-16 04:08:24 +00:00
1 parent e0bf102f2a
commit d29b0706c9
36 files changed
+257 -244

No files matched your search

+2 -2
View File
@@ -10,7 +10,7 @@
*/
#include "cat/value.h"
#include "cat/error.h"
#include "cat/types/nil.h"
#include "cat/types/empty.h"
#include "cat/types/bool.h"
#include "cat/types/int.h"
#include "cat/types/float.h"
@@ -211,7 +211,7 @@ int cat_value_slot_get(CAT_VALUE_Value *v, const CAT_VALUE_Slot *s,
: cat_types_bool_false();
break;
default:
*out = cat_types_nil_get();
*out = cat_types_empty();
break;
}
if (*out == NULL)