Add lambda special form

This commit is contained in:
2022-11-04 21:51:25 -04:00
parent c37e46e354
commit 2344a7d498
3 changed files with 16 additions and 2 deletions

View File

@@ -71,12 +71,24 @@ struct ucl_object *ucl_special_defun(struct ucl_state *state, struct ucl_object
}
struct ucl_object *ucl_special_lambda(struct ucl_state *state, struct ucl_object *args) {
// TODO: Check arguments
struct ucl_object *fun_args = ucl_list_nth(args, 0);
if (fun_args->type != UCL_TYPE_CELL) {
// TODO: Check that the list contains only symbols
return ucl_error_create("First argument to lambda must be a list of symbols");
}
return args;
}
struct ucl_object *ucl_special_setq(struct ucl_state *state, struct ucl_object *args) {
// TODO: Check arguments
struct ucl_object *sym = ucl_car(args);
struct ucl_state *root_state = ucl_state_get_root(state);
if (sym->type != UCL_TYPE_SYMBOL) {
return ucl_error_create("First argument to defun must be a symbol");
return ucl_error_create("First argument to setq must be a symbol");
}
struct ucl_object *value = ucl_evaluate(state, ucl_list_nth(args, 1));