Welcome to the CHICKEN Scheme pasting service

live define in block-ref added by randart on Mon Jun 3 17:49:29 2019

(module live (define)
(import (rename scheme (define define0)) chicken)
(import-for-syntax matchable chicken)

(define-for-syntax ((procedure-sym? inj) s)
  (procedure? (block-ref (inj s) 0)))

(define-syntax define
  (ir-macro-transformer
    (lambda (sexp inject compare)
      (match sexp
        ((_ ((and name (? (procedure-sym? inject))) . args) . body)
         `(mutate-procedure! ,name (lambda (old) (lambda ,args ,@body))))
        ((_ (and name (? (procedure-sym? inject))) ((? (cut compare 'lambda <>)) args . body))
         `(mutate-procedure! ,name (lambda (old) (lambda ,args ,@body))))
        (else
          `(define0 ,@(cdr sexp))))
         )))
)
(import live)

Your annotation:

Enter a new annotation:

Your nick:
The title of your paste:
Your paste (mandatory) :
Type in the text below:
       _     _             _     
  ___ | |__ | |_ ___  __ _| |__  
 / _ \| '_ \| __/ _ \/ _` | '_ \ 
| (_) | | | | ||  __/ (_| | | | |
 \___/|_| |_|\__\___|\__, |_| |_|
                     |___/       
Visually impaired? Let me spell it for you (wav file) download WAV