PLQ #11Done on:   Tuesday, April 6th

Question 1 @ 2021-04-06 18:18

Consider the two following macro definitions for bind from the last lecture:

(define-macro (bind var-expr-list body)
  (if (andmap (lambda (var-expr)
                (and (list? var-expr)
                    (= 2 (length var-expr))
                    (symbol? (car var-expr))))
    `((lambda ,(map car var-expr-list) ,body)
      ,@(map cadr var-expr-list))
    (error 'bind "bad syntax whaaaa!")))


(define-syntax bind
  (syntax-rules ()
    [(bind ((var expr) ...) body ...)
    ((lambda (var ...) body ...) expr ...)]))

What functionality do we lose when translating from the first definition to the second definition?

(Choose the best answer, the one that you’d care most about.)

Question 2 @ 2021-04-06 18:22

What does the following macro do?

(define-syntax foo
  (syntax-rules ()
    [(foo (var) exp)
    (λ (var) exp)]
    [(foo (var-1 var-2 var-more ...) exp)
    (λ (var-1) (foo (var-2 var-more ...) exp))]))