Revert "redefine def to take two arguments"
This reverts commit 239fbeff13.
			
			
This commit is contained in:
		
							parent
							
								
									d338423ce3
								
							
						
					
					
						commit
						b7e5ec69a2
					
				|  | @ -65,16 +65,16 @@ mumble> eval { head {1 2 3} } | ||||||
| mumble> (eval { head {+ tail head } } ) 1 2 3  | mumble> (eval { head {+ tail head } } ) 1 2 3  | ||||||
| mumble> len {1 2 3} | mumble> len {1 2 3} | ||||||
| mumble> join { {1 2} {3 4} } | mumble> join { {1 2} {3 4} } | ||||||
| mumble> def {x} { 100 } | mumble> def { {x} { 100 } } | ||||||
| mumble> x | mumble> x | ||||||
| mumble> def { a b c } { 1 2 3} | mumble> def { { a b c } { 1 2 3} } | ||||||
| mumble> * a b c | mumble> * a b c | ||||||
| mumble> - a b c | mumble> - a b c | ||||||
| mumble> / a b c | mumble> / a b c | ||||||
| mumble> VERBOSITY=0 | mumble> VERBOSITY=0 | ||||||
| mumble> VERBOSITY=1 | mumble> VERBOSITY=1 | ||||||
| mumble> VERBOSITY=2 | mumble> VERBOSITY=2 | ||||||
| mumble> def {plus} {(@ {x y} {+ x y})} | mumble> def { {plus} {(@ {x y} {+ x y})} } | ||||||
| ( ) | ( ) | ||||||
| mumble> plus | mumble> plus | ||||||
| ( @ { x y } { + x y } ) | ( @ { x y } { + x y } ) | ||||||
|  |  | ||||||
							
								
								
									
										23
									
								
								src/mumble.c
									
									
									
									
									
								
							
							
						
						
									
										23
									
								
								src/mumble.c
									
									
									
									
									
								
							|  | @ -733,20 +733,19 @@ lispval* builtin_join(lispval* l, lispenv* e) | ||||||
| // Define a variable
 | // Define a variable
 | ||||||
| lispval* builtin_def(lispval* v, lispenv* env) | lispval* builtin_def(lispval* v, lispenv* env) | ||||||
| { | { | ||||||
|     // Takes two arguments: def { a b } { 1 2 }
 |     // Takes one argument: def { { a b } { 1 2 } }
 | ||||||
|     LISPVAL_ASSERT(v->count == 2, "Error: function def passed something other than 2 arguments"); |     lispval* source = v->cell[0]; | ||||||
| 		 |     LISPVAL_ASSERT(v->count == 1, "Error: function def passed too many arguments"); | ||||||
| 		lispval* symbols = v->cell[0]; |     LISPVAL_ASSERT(source->type == LISPVAL_QEXPR, "Error: Argument passed to def is not a q-expr, i.e., a bracketed list."); | ||||||
| 		lispval* values = v->cell[1]; |     LISPVAL_ASSERT(source->count == 2, "Error: Argument passed to def should be a q expr with two q expressions as children: def { { a b } { 1 2 } } "); | ||||||
| 		symbols = evaluate_lispval(symbols, env); |     LISPVAL_ASSERT(source->cell[0]->type == LISPVAL_QEXPR, "Error: Argument passed to def should be a q expr with two q expressions as children: def { { a b } { 1 2 } } "); | ||||||
| 		values = evaluate_lispval(values, env); |     LISPVAL_ASSERT(source->cell[1]->type == LISPVAL_QEXPR || source->cell[1]->type == LISPVAL_SEXPR, "Error: Argument passed to def should be a q expr with two q expressions as children: def { { a b } { 1 2 } } "); | ||||||
|      |     LISPVAL_ASSERT(source->cell[0]->count == source->cell[1]->count, "Error: In function \"def\" both subarguments should have the same length"); | ||||||
| 		LISPVAL_ASSERT(symbols->type == LISPVAL_QEXPR, "Error: Argument passed to def is not a q-expr, i.e., a bracketed list."); |  | ||||||
| 		LISPVAL_ASSERT(values->type == LISPVAL_QEXPR, "Error: Argument passed to def is not a q-expr, i.e., a bracketed list."); |  | ||||||
|     LISPVAL_ASSERT(symbols->count == values->count, "Error: In function \"def\" both subarguments should have the same length"); |  | ||||||
| 
 | 
 | ||||||
|  |     lispval* symbols = source->cell[0]; | ||||||
|  |     lispval* values = source->cell[1]; | ||||||
|     for (int i = 0; i < symbols->count; i++) { |     for (int i = 0; i < symbols->count; i++) { | ||||||
|         LISPVAL_ASSERT(symbols->cell[i]->type == LISPVAL_SYM, "Error: in function def, the first list of items should be of type symbol:  def { a b } { 1 2 } "); |         LISPVAL_ASSERT(symbols->cell[i]->type == LISPVAL_SYM, "Error: in function def, the first list of items should be of type symbol:  def { { a b } { 1 2 } }"); | ||||||
|         if (VERBOSE) |         if (VERBOSE) | ||||||
|             print_lispval_tree(symbols, 0); |             print_lispval_tree(symbols, 0); | ||||||
|         if (VERBOSE) |         if (VERBOSE) | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue
	
	Block a user