guile-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

with-slots and symbol-macros


From: Nicolas Sceaux
Subject: with-slots and symbol-macros
Date: Sun, 16 May 2004 23:38:53 +0200
User-agent: Gnus/5.1006 (Gnus v5.10.6) Emacs/21.3 (gnu/linux)

Hello,

I am trying to write a variation of CL's WITH-SLOTS for GNU LilyPond,
which uses guile scheme (1.6.4 is installed on my box).

(with-properties (element origin) music-object
  (display origin)
  (set! element (make-music blabla)))

<==>

(let ((#gensym-music# music-object))
  (display (ly:music-property #gensym-music# 'origin))
  (set! (ly:music-property #gensym-music# 'element) (make-music blabla)))

I would like to introduce symbol macros, for instance:
  element
that would expand into:
  (ly:music-property #gensym-music# 'element)
which is setf-able.

I am not familiar with define-syntax and friends. What I have come up
to is:

guile> (define mycar (make-procedure-with-setter car set-car!))
guile> (let-syntax ((car-a (lambda (exp)
                             (syntax-case exp ()
                               (_ (syntax (mycar a)))))))
         (let ((a (list 1 2 3)))
           (+ car-a 3)))
4
guile> (let-syntax ((car-a (lambda (exp)
                             (syntax-case exp ()
                               (_ (syntax (mycar a)))))))
         (let ((a (list 1 2 3)))
           (set! car-a 3)
           a))
ERROR: invalid syntax (set! car-a 3)
ABORT: (misc-error)

That is, set! remains problematic.

In spite of intensive googling, I could not find an example that could
work in guile scheme. A clue is most welcome. Or am I using a wrong
approach?

Please cc: me (nicolas.sceaux AT free.fr) as I'm not subscribed to the
ml.

Best regards,
nicolas





reply via email to

[Prev in Thread] Current Thread [Next in Thread]