* lisp-syntax-transformer
@ 2000-05-08 9:51 hello
2000-05-08 10:04 ` lisp-syntax-transformer Keisuke Nishida
0 siblings, 1 reply; 2+ messages in thread
From: hello @ 2000-05-08 9:51 UTC (permalink / raw)
To: guile-emacs
Hello,
(define-class <lisp-variable> ()
(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 <lisp-variable>) port)
(display "#<lisp-variable " port)
(display (sym obj) port)
(display ">" port))
(define user-full-name (make <lisp-variable> #:symbol 'user-full-name))
user-full-name => #<lisp-variable user-full-name>
(lisp-value user-full-name) => #<foreign-object <emacs-string> 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 => #<foreign-object <emacs-string> 4042a298>
(%lisp->scheme $user-full-name) => "hello"
Any comment?
-- Kei
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2000-05-08 10:04 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-05-08 9:51 lisp-syntax-transformer hello
2000-05-08 10:04 ` lisp-syntax-transformer Keisuke Nishida
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).