From: jsancho Date: Wed, 7 Sep 2011 18:04:47 +0000 (+0000) Subject: (no commit message) X-Git-Url: https://git.jsancho.org/?a=commitdiff_plain;h=bfe80b0d01f83148263ba4c12197629c29b80cd1;p=gacela.git --- diff --git a/src/gacela_mobs.scm b/src/gacela_mobs.scm index 1012301..a9c13fa 100755 --- a/src/gacela_mobs.scm +++ b/src/gacela_mobs.scm @@ -49,7 +49,11 @@ (define-macro (show-mob mob) - `(show-mob-hash ',mob (lambda (option) (,mob option)))) + (cond ((list? mob) + `(let ((m ,mob)) + (show-mob-hash (m 'get-mob-id) m))) + (else + `(show-mob-hash (,mob 'get-mob-id) (lambda () (,mob)))))) (define-macro (hide-mob mob) `(hide-mob-hash ',mob)) @@ -191,17 +195,6 @@ (lambda () (look attr)) (lambda (key . args) #f))))))))) -(define-macro (define-mob mob-head . body) - (let ((name (car mob-head)) (attr (cdr mob-head))) - `(define ,(string->symbol (string-concatenate (list "make-" (symbol->string name)))) - (lambda-mob ,attr ,@body)))) - -(define-macro (lambda-mob attr . body) - `(lambda () - (let ,(cons '(mob-id (gentemp)) attr) - (lambda () - ,@body)))) - (define (get-mob-attr mob var) (let ((value (assoc-ref (mob 'get-attr) var))) @@ -215,3 +208,24 @@ (define (set-mob-look! mob look) (mob 'set-look look)) + + + + + +(define-macro (define-mob mob-head . body) + (let ((name (car mob-head)) (attr (cdr mob-head))) + `(define ,(string->symbol (string-concatenate (list "make-" (symbol->string name)))) + (lambda-mob ,attr ,@body)))) + +(define-macro (lambda-mob attr . body) + `(lambda () + (let ,(cons '(mob-id (gensym)) attr) + (lambda* (#:optional (option #f)) + (case option + ((get-mob-id) + mob-id) + (else + (catch #t + (lambda () ,@body) + (lambda (key . args) #f))))))))