`(,let-keyword ,bindings ,@body)))
`(,let-keyword ,bindings ,@body))))
+(define-syntax :letrec
+ (er-macro-transformer
+ (lambda (form rename compare)
+ (declare (ignore compare))
+ (syntax-check '(KEYWORD (* (IDENTIFIER ? EXPRESSION)) + FORM) form)
+ (let ((bindings (cadr form))
+ (r-lambda (rename 'LAMBDA))
+ (r-named-lambda (rename 'NAMED-LAMBDA))
+ (r-set! (rename 'SET!)))
+ (let ((temps (map (lambda (binding)
+ (make-synthetic-identifier
+ (identifier->symbol (car binding)))) bindings)))
+ `((,r-named-lambda (,lambda-tag:unnamed ,@(map car bindings))
+ ((,r-lambda ,temps
+ ,@(map (lambda (binding temp)
+ `(,r-set! ,(car binding) ,temp)) bindings temps))
+ ,@(map cadr bindings))
+ ((,r-lambda () ,@(cddr form))))
+ ,@(map (lambda (binding)
+ (declare (ignore binding))
+ (unassigned-expression)) bindings)))))))
+
+(define-syntax :letrec*
+ (er-macro-transformer
+ (lambda (form rename compare)
+ (declare (ignore compare))
+ (syntax-check '(KEYWORD (* (IDENTIFIER ? EXPRESSION)) + FORM) form)
+ (let ((bindings (cadr form))
+ (r-lambda (rename 'LAMBDA))
+ (r-named-lambda (rename 'NAMED-LAMBDA))
+ (r-set! (rename 'SET!)))
+ `((,r-named-lambda (,lambda-tag:unnamed ,@(map car bindings))
+ ,@(map (lambda (binding)
+ `(,r-set! ,@binding)) bindings)
+ ((,r-lambda () ,@(cddr form))))
+ ,@(map (lambda (binding)
+ (declare (ignore binding))
+ (unassigned-expression)) bindings))))))
+\f
(define-syntax :and
(er-macro-transformer
(lambda (form rename compare)
`(,r-begin
(,r-declare (INTEGRATE-OPERATOR ,(caadr form)))
(,r-define ,(cadr form)
- (,r-declare (INTEGRATE ,@(cdadr form)))
+ ,@(let ((arguments (cdadr form)))
+ (if (null? arguments)
+ '()
+ `((,r-declare (INTEGRATE ,@arguments)))))
,@(cddr form))))
(else
(ill-formed-syntax form)))))))
variable-binding-theory
output/let)))))
-(define (classifier:letrec form environment definition-environment)
- definition-environment
- (syntax-check '(KEYWORD (* (IDENTIFIER ? EXPRESSION)) + FORM) form)
- (let* ((binding-environment
- (make-internal-syntactic-environment environment))
- (value-environment
- (make-internal-syntactic-environment binding-environment))
- (body-environment
- (make-internal-syntactic-environment binding-environment)))
- (for-each (let ((item (make-reserved-name-item)))
- (lambda (binding)
- (syntactic-environment/define binding-environment
- (car binding)
- item)))
- (cadr form))
- (classify/let-like form
- value-environment
- binding-environment
- body-environment
- variable-binding-theory
- output/letrec)))
-
-(define (classifier:letrec* form environment definition-environment)
- definition-environment
- (syntax-check '(KEYWORD (* (IDENTIFIER ? EXPRESSION)) + FORM) form)
- (let* ((binding-environment
- (make-internal-syntactic-environment environment))
- (body-environment
- (make-internal-syntactic-environment binding-environment)))
- (for-each (let ((item (make-reserved-name-item)))
- (lambda (binding)
- (syntactic-environment/define binding-environment
- (car binding)
- item)))
- (cadr form))
- (classify/let-like form
- binding-environment
- binding-environment
- body-environment
- variable-binding-theory
- output/letrec*)))
\f
(define (classifier:let-syntax form environment definition-environment)
definition-environment