allow naked special forms

This commit is contained in:
Sami Samhuri 2011-04-21 15:40:31 -07:00
parent cb7b786ffd
commit 2efdbae78a
3 changed files with 5 additions and 3 deletions

View file

@ -167,7 +167,7 @@ static void init_special_form_handlers(void)
/* HANDLER("letrec", &letrec_special_form); */ /* HANDLER("letrec", &letrec_special_form); */
} }
static gboolean is_special_form(LakeList *expr) gboolean is_special_form(LakeList *expr)
{ {
if (special_form_handlers == NULL) { if (special_form_handlers == NULL) {
init_special_form_handlers(); init_special_form_handlers();

View file

@ -16,5 +16,6 @@
LakeVal *eval(Env *env, LakeVal *expr); LakeVal *eval(Env *env, LakeVal *expr);
LakeList *eval_exprs(Env *env, LakeList *exprs); LakeList *eval_exprs(Env *env, LakeList *exprs);
LakeVal *apply(LakeVal *fnVal, LakeList *args); LakeVal *apply(LakeVal *fnVal, LakeList *args);
gboolean is_special_form(LakeList *expr);
#endif #endif

View file

@ -78,8 +78,9 @@ static LakeVal *prompt_read(Env *env, char *prompt)
LakeVal *result; LakeVal *result;
/* naked call */ /* naked call */
LakeVal *head = eval(env, LIST_VAL(list, 0)); LakeVal *head;
if (LIST_N(list) > 1 && CALLABLE(head)) { if (is_special_form(list) ||
(LIST_N(list) > 1 && (head = eval(env, LIST_VAL(list, 0))) && CALLABLE(head))) {
result = VAL(list); result = VAL(list);
} }