;(define-syntax while ; (syntax-rules () ; [(_ e1 e2 ...) ; (let loop ([cond e1]) ; (if cond ; (begin ; (begin e2 ...) ; (loop e1))))])) ;;; The problem is that cond and bodies gets evaluated before being ;;; passed to while because it is an application. We'd have to call ;;; while with (lambda () cond) and ;;; (lambda () body) (lambda () body) ... (define while (lambda (cond . bodies) (let loop ([condition cond]) (if condition (begin (eval-bodies bodies) (loop cond)))))) (define eval-bodies (lambda (bodies) (if (not (null? bodies)) (begin (car bodies) (eval-bodies (cdr bodies)))))) (define-syntax return-first (syntax-rules () [(_) (begin)] [(_ e1 e2 ...) (let ([temp e1]) e2 ... temp)]))