SapphireDensetsu / ypsilon

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

free-identifier=? broken #33

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
free-identifier=? compares identifiers' spelling / name only when the
identifiers are both unbound.

Ypsilon 0.9.6 Copyright (c) 2008 Y.Fujita, LittleWing Company Limited.
> 
(library (L)
  (export x s)
  (import (rnrs))

  (define-syntax x (lambda (_) #f))

  (define-syntax s
    (syntax-rules (x)  ;; This x refers only to the one in scope above.
      [(_ x)  ;; This pattern matches only if the 2nd subform is an
identifier that is free-identifier=? to the x in the literals list.
       'ok]))  
)
> (import (prefix (L) L:))
> (L:s L:x)  ;; This should work.

error in L:s: invalid syntax
  >  (L:s L:x)
  ..."/dev/stdin" line 1
  @  (syntax-rules (x) ((_ x) 'ok))
  ..."/dev/stdin" line 9

> (L:s x)  ;; This should not work.
ok
> 

Similarly:

[New session with same definition of library (L)]

> (import (L))
> (let ([x 'something-else])
    (s x))  ;; This x refers to a different binding: the let one in scope.
ok  ;; Should not have worked.
> 

See this for more:
https://bugs.launchpad.net/ikarus/+bug/248476

Original issue reported on code.google.com by derick.e...@gmail.com on 1 Aug 2008 at 7:26

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

Original comment by y.fujita...@gmail.com on 2 Aug 2008 at 4:54

GoogleCodeExporter commented 8 years ago
I have fixed the bug and trunk directory is updated. Please try.
Thank you!

Original comment by y.fujita...@gmail.com on 5 Aug 2008 at 4:52

GoogleCodeExporter commented 8 years ago
free-identifier=? is still broken in this way:

$ cat stuff.sls 
(library (stuff)
  (export x)
  (import (rnrs))
  (define x 1))
$ cat use-stuff.sps 
(import (rnrs)
        (stuff)
        (prefix (stuff) stuff:))

(define-syntax is-free-id=?
  (lambda (stx)
    (syntax-case stx ()
      ((_ x y)
       (free-identifier=? #'x #'y)))))

(write (is-free-id=? x stuff:x))
(newline)
$ ypsilon --sitelib . use-stuff.sps 
#f
$

The result should be #T.

Original comment by derick.e...@gmail.com on 1 May 2009 at 4:28

GoogleCodeExporter commented 8 years ago
I found current repl and compatible mode have problems with free-identifier=?, 
but I
do not have good solution yet. :(
Please use --r6rs flag or #!r6rs comment to get correct result at this moment. 
Thank you!
-- fujita

$ ypsilon --sitelib=. use-stuff.sps
#f ;; incorrect

$ ypsilon --r6rs --sitelib=. use-stuff.sps
#t ;; correct

Original comment by y.fujita...@gmail.com on 2 May 2009 at 2:59

GoogleCodeExporter commented 8 years ago
OK, thanks.  --r6rs gives the correct result for me.  I did not know --r6rs is
required to get R6RS semantics.  I thought --r6rs only affected the lexical 
syntax. 
I suggest changing the --help printout and the manpage to describe that --r6rs 
is not
only about lexical syntax, it also affects the execution mode.

Original comment by derick.e...@gmail.com on 2 May 2009 at 10:13

GoogleCodeExporter commented 8 years ago
Thank you for your suggestion. I have updated help and man page.

> I thought --r6rs only affected the lexical syntax.
Since my intention is that --r6rs does not affect to the result of proper R6RS
top-level program, I count current behavior of free-identifier=? is the bug. I 
will
try fix it. :)

-- fujita

Original comment by y.fujita...@gmail.com on 5 May 2009 at 12:56

GoogleCodeExporter commented 8 years ago
The bug fixed in revision 443. It produce correct result without --r6rs flag, 
also it
produce correct result in emacs. Thank you. :)
-- fujita

$ ypsilon --r6rs use-stuff.scm
#t

$ ypsilon use-stuff.scm
#t

;; (scheme-send-last-sexp) for each expression from 1 to 4 shows correct result 
in emacs.
(library (stuff)
  (export x)
  (import (rnrs))
  (define x 1)) ;; <- 1

(import (rnrs)
        (stuff)
        (prefix (stuff) stuff:)) ;; <- 2

(define-syntax is-free-id=?
  (lambda (stx)
    (syntax-case stx ()
      ((_ x y)
       (free-identifier=? #'x #'y))))) ;; <- 3

(write (is-free-id=? x stuff:x)) ;; <- 4

Original comment by y.fujita...@gmail.com on 6 May 2009 at 2:56