Welcome to the CHICKEN Scheme pasting service

no title added by buhman on Mon Dec 3 10:04:28 2018

(define-record-type foo
  (make-foo x y)
  foo?
  (x foo-x)
  (y foo-y))

(define-syntax test
  (ir-macro-transformer
   (lambda (exp inject compare)
     (let* ((type (cadr exp))
            (body (cddr exp))
            (get-x (inject (symbol-append (strip-syntax type) '- (strip-syntax 'x))))
            (get-y (inject (symbol-append (strip-syntax type) '- (strip-syntax 'y)))))
       `(let ((thing ,@body))
          (list (,get-x thing) (,get-y thing)))))))

#;456> (test foo (make-foo 1 2))
(1 2)
#;460> (define my-type 'foo)
#;476> (test my-type (make-foo 1 2))

Error: unbound variable: my-type-x

Your annotation:

Enter a new annotation:

Your nick:
The title of your paste:
Your paste (mandatory) :
What's the procedure that returns the car of a cdr?
Visually impaired? Let me spell it for you (wav file) download WAV