(module bind mzscheme
  (require (lib "defmacro.ss" "mzlib"))
  
  (define-macro bind
    (lambda (bindings . body)
      (define (get-bindings bindings)
        (if (equal? bindings `())
            `()
            (let ([vector-parts (map (lambda (part)
                                       (string->symbol (string-append (symbol->string (caar bindings))
                                                                      "."
                                                                      (symbol->string part))))
                                     (cdar bindings))])
              (define (iter parts num)
                (if (equal? parts `())
                    `()
                    (cons `(,(car parts) (vector-ref ,(caar bindings)
                                                     ,num))
                          (iter (cdr parts)
                                (+ num 1)))))
              (append (iter vector-parts 0)
                      (get-bindings (cdr bindings))))))
      `(let ,(get-bindings bindings) ,@body)))
  
  (provide bind))

