Add lambda special form
This commit is contained in:
@@ -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));
|
||||
|
||||
Reference in New Issue
Block a user