All unit tests pass. The eval-quote problem is solved.

This commit is contained in:
Simon Brooke 2018-12-07 06:43:23 +00:00
parent fd9c851185
commit 645ab3674e
2 changed files with 18 additions and 31 deletions

View file

@ -86,6 +86,7 @@ int main( int argc, char *argv[] ) {
bind_function( "cons", &lisp_cons ); bind_function( "cons", &lisp_cons );
bind_function( "eq", &lisp_eq ); bind_function( "eq", &lisp_eq );
bind_function( "equal", &lisp_equal ); bind_function( "equal", &lisp_equal );
bind_function( "eval", &lisp_eval );
bind_function( "multiply", &lisp_multiply ); bind_function( "multiply", &lisp_multiply );
bind_function( "read", &lisp_read ); bind_function( "read", &lisp_read );
bind_function( "print", &lisp_print ); bind_function( "print", &lisp_print );
@ -101,7 +102,6 @@ int main( int argc, char *argv[] ) {
* primitive special forms * primitive special forms
*/ */
bind_special( "cond", &lisp_cond ); bind_special( "cond", &lisp_cond );
bind_function( "eval", &lisp_eval );
bind_special( "quote", &lisp_quote ); bind_special( "quote", &lisp_quote );

View file

@ -36,8 +36,6 @@
/* /*
* also to create in this section: * also to create in this section:
* struct cons_pointer lisp_cond( struct cons_pointer args, struct cons_pointer env,
struct stack_frame* frame);
* struct cons_pointer lisp_let( struct cons_pointer args, struct cons_pointer env, * struct cons_pointer lisp_let( struct cons_pointer args, struct cons_pointer env,
struct stack_frame* frame); struct stack_frame* frame);
* struct cons_pointer lisp_mapcar( struct cons_pointer args, struct cons_pointer env, * struct cons_pointer lisp_mapcar( struct cons_pointer args, struct cons_pointer env,
@ -179,7 +177,7 @@ struct cons_pointer c_type( struct cons_pointer pointer ) {
/** /**
* (eval s_expr) * (eval s_expr)
* *
* Special form. * function.
* If s_expr is a number, NIL, or T, returns s_expr. * If s_expr is a number, NIL, or T, returns s_expr.
* If s_expr is an unprotected string, returns the value that s_expr is bound * If s_expr is an unprotected string, returns the value that s_expr is bound
* to in the evaluation environment (env). * to in the evaluation environment (env).
@ -200,17 +198,6 @@ lisp_eval( struct stack_frame *frame, struct cons_pointer env ) {
switch ( cell.tag.value ) { switch ( cell.tag.value ) {
case CONSTV: case CONSTV:
result = c_apply( frame, env ); result = c_apply( frame, env );
/* I have a profound misunderstanding of how quote and eval should interact!
* if ( equal( c_car(frame->arg[0]), c_string_to_lisp_symbol("quote")))
* /\* car is QUOTE. TODO: It is ABSURDLY expensive to 'equal' each time! *\/
* {
* /\* we need to eval it again *\/
* frame->arg[0] = result;
* fputws( L"quote - re-evaling", stderr);
* dump_frame( stderr, frame );
* result = c_apply(frame, env);
* } */
break; break;
case SYMBOLTV: case SYMBOLTV: