unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
* more syntax silliness
@ 2002-08-19 15:54 Lynn Winebarger
  2002-08-24  4:54 ` Lynn Winebarger
  0 siblings, 1 reply; 4+ messages in thread
From: Lynn Winebarger @ 2002-08-19 15:54 UTC (permalink / raw)



You can still get dynamic redefinition of syntax:

(define tmp
  (let ((x 5))
    (list
      (lambda (y) (set! x y))
      (lambda () x)
      (lambda (exp)
          (syntax-case exp ()
	  ((_ z) (with-syntax ((x2 (datum->syntax-object (syntax _) x)))
		   (syntax '(z x2)))))))))

  
(define setx (car tmp))
(define getx (cadr tmp))
(define-syntax foo (caddr tmp))

> (foo bar)
(bar 8)
> (setx 3)
> (let-syntax ((baz (caddr tmp)))
    (display (baz bar))
    (newline)
    (setx 'different)
    (display (baz bar))
    (newline)
    (display (foo bar))
    (newline))
(bar 3)
(bar 3)
(bar 3)
>  (foo bar)
(bar different)

    Now here's the fun part:
> (setx 2)
> (let-syntax ((baz (caddr tmp)))
    (display (baz bar))
    (newline)
    (let-syntax ((foo (let ()
			(setx 3)
			(caddr tmp))))
      (display (baz bar))
      (newline)
      (display (foo bar))
      (newline))
    (display (baz bar))
    (newline))
(bar 2)
(bar 2)
(bar 3)
(bar 3)
> (setx 2)
> (let-syntax ((baz (caddr tmp)))
    (display (baz bar))
    (newline)
    (let-syntax ((foo (let ()
			(setx 3)
			(caddr tmp))))
      (display (foo bar))
      (newline)
      (display (baz bar))
      (newline))
    (display (baz bar))
    (newline))
(bar 2)
(bar 3)
(bar 3)
(bar 3)
> 

    I don't know why the first and the second don't have the same output.  
That is, it appears the inner foo's definition doesn't get evaluated until
that foo is actually used.  This seems to me a mistake in Chez, but I could be
wrong.

Lynn




_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-devel


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2002-08-26 22:30 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-08-19 15:54 more syntax silliness Lynn Winebarger
2002-08-24  4:54 ` Lynn Winebarger
2002-08-26 21:53   ` Marius Vollmer
2002-08-26 22:30     ` Lynn Winebarger

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).