shhyou / ypsilon-fork

Automatically exported from code.google.com/p/ypsilon
Other
0 stars 0 forks source link

generate-temporaries / gensym broken #41

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
This should cause an "unbound variable" error but it does not:

;;------------------ gen-temp.sps --------------------
(import (rnrs))

(define \x2E;L0 1)

(define-syntax s
  (lambda (_)
    (with-syntax ([t (car (generate-temporaries '(1)))])
      #'(+ 1 t))))

(write (s)) (newline)
;;----------------------------------------------------

$ ypsilon gen-temp.sps 
2
$

These should not be equal:

Ypsilon 0.9.6-trunk/r171 Copyright (c) 2008 Y.Fujita, LittleWing Company
Limited.
> (define g (gensym))
> g
\x2E;G34
> (eq? g '\x2E;G34)
#t
> (define t (syntax->datum (car (generate-temporaries '(1)))))
> t
\x2E;L0
> (eq? t '\x2E;L0)
#t
> 

This is important for macro hygiene.  Even if gensyms have the same
spelling as normal symbols, they're supposed to never be equal to any
symbol except for themselves.  E.g., MzScheme:

Welcome to MzScheme v4.0.2.6 [3m], Copyright (c) 2004-2008 PLT Scheme Inc.
> (define g (gensym))
> g
g47
> (eq? g 'g47)
#f
> 

I believe most implementations accomplish this by using separate symbol
tables for normal symbols and gensyms.

Original issue reported on code.google.com by derick.e...@gmail.com on 17 Aug 2008 at 4:01

GoogleCodeExporter commented 9 years ago
Thank you for your bug report!

Original comment by y.fujita...@gmail.com on 18 Aug 2008 at 2:31

GoogleCodeExporter commented 9 years ago
I have fixed the bug and trunk directory updated to revision 175. Please try.
Thank you!

Original comment by y.fujita...@gmail.com on 21 Aug 2008 at 4:06