From mboxrd@z Thu Jan 1 00:00:00 1970 From: hello To: guile-emacs@sourceware.cygnus.com Subject: lisp-syntax-transformer Date: Mon, 08 May 2000 09:51:00 -0000 Message-id: X-SW-Source: 2000-q2/msg00041.html Hello, (define-class () (sym #:accessor sym #:init-keyword #:symbol) (var #:allocation #:virtual #:slot-ref (lambda (i) (%lisp-eval (sym i))) #:slot-set! (lambda (i v) (%lisp-eval `(setq ,(sym i) ',v)) *unspecified*) #:accessor lisp-value)) (define-method (write (obj ) port) (display "#" port)) (define user-full-name (make #:symbol 'user-full-name)) user-full-name => # (lisp-value user-full-name) => # 4047e070> (define (transformer x) (let ((lisp-symbol? (lambda (o) (eq? (string-ref o 0) #\$))) (lisp-value (lambda (o) (list 'lisp-value (string->symbol (substring o 1)))))) (if (and (symbol? x) (lisp-symbol? x)) (lisp-value x) (letrec ((trans! (lambda (x) (cond ((pair? x) (if (symbol? (car x)) (if (lisp-symbol? (car x)) (set-car! x (lisp-value (car x)))) (trans! (car x))) (trans! (cdr x))))))) (trans! x) x)))) (transformer '$foo) => (lisp-value foo) (transformer '(set! $foo #t)) => (set! (lisp-value foo) #t) (use-syntax transformer) (set! $user-full-name "hello") $user-full-name => # 4042a298> (%lisp->scheme $user-full-name) => "hello" Any comment? -- Kei