Add setq special form
This commit is contained in:
@@ -76,3 +76,17 @@ struct ucl_object *ucl_special_defun(struct ucl_state *state, struct ucl_object
|
||||
return fun_sym;
|
||||
|
||||
}
|
||||
|
||||
struct ucl_object *ucl_special_setq(struct ucl_state *state, struct ucl_object *args) {
|
||||
// TODO: Check arguments
|
||||
struct ucl_object *sym = ucl_car(args);
|
||||
if (sym->type != UCL_TYPE_SYMBOL) {
|
||||
return ucl_error_create("First argument to defun must be a symbol");
|
||||
}
|
||||
|
||||
struct ucl_object *value = ucl_evaluate(state, ucl_list_nth(args, 1));
|
||||
|
||||
ucl_state_put(ucl_state_get_root(state), sym->symbol, value);
|
||||
|
||||
return sym;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user