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:
1 parent
e0bf102f2a
commit
d29b0706c9
36 files changed
+257
-244
No files matched your search
@@ -11,7 +11,7 @@
|
||||
#include "cat/bytecode.h"
|
||||
#include "cat/types/table.h"
|
||||
#include "cat/types/int.h"
|
||||
#include "cat/types/nil.h"
|
||||
#include "cat/types/empty.h"
|
||||
#include "cat/types/ascii_text.h"
|
||||
#include "cat/error.h"
|
||||
|
||||
@@ -97,7 +97,7 @@ static int lf_bc_run(CAT_VM_State *vm, CAT_VALUE_Value **args, int nargs,
|
||||
}
|
||||
fn = build_function(args[0]);
|
||||
if (fn == NULL) {
|
||||
*out = cat_types_nil_get();
|
||||
*out = cat_types_empty();
|
||||
return 0;
|
||||
}
|
||||
rc = cat_vm_run(vm, fn, out);
|
||||
@@ -112,7 +112,7 @@ static int lf_bc_dump(CAT_VM_State *vm, CAT_VALUE_Value **args, int nargs,
|
||||
|
||||
(void)vm;
|
||||
if (nargs < 1) {
|
||||
*out = cat_types_nil_get();
|
||||
*out = cat_types_empty();
|
||||
return 0;
|
||||
}
|
||||
fn = build_function(args[0]);
|
||||
@@ -120,7 +120,7 @@ static int lf_bc_dump(CAT_VM_State *vm, CAT_VALUE_Value **args, int nargs,
|
||||
cat_bytecode_dump(fn, stdout);
|
||||
cat_bytecode_function_free(fn);
|
||||
}
|
||||
*out = cat_types_nil_get();
|
||||
*out = cat_types_empty();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user