Welcome to the CHICKEN Scheme pasting service

simple-generic added by dieggsy on Fri Jan 29 22:29:25 2021

(module simple-generic (define-generic
             define-method)
  (import scheme)
  (import-for-syntax (only srfi-1 zip))
  (define-syntax define-generic
    (syntax-rules ()
      ((_ name)
       (define (name . rest)
         (import chicken.base)
         (error "No matching methods for args" rest)))))

  (define-syntax define-method
    (er-macro-transformer
     (lambda (x r c)
       (let* ((name (caadr x))
              (args (cdadr x))
              (argnames (map cadr args))
              (preds (map car args))
              (body (cddr x)))
         `(let ((old ,name))
            (set! ,name
              (lambda ,argnames
                (if (and ,@(zip preds argnames))
                    (begin
                      ,@body)
                    (old ,@argnames))))))))))

Your annotation:

Enter a new annotation:

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