bug-kawa
[Top][All Lists]
Advanced

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

[Bug-kawa] [bug #37051] define-syntax does not work when included


From: anonymous
Subject: [Bug-kawa] [bug #37051] define-syntax does not work when included
Date: Wed, 08 Aug 2012 00:34:36 +0000
User-agent: Mozilla/5.0 (X11; Linux i686; rv:14.0) Gecko/20100101 Firefox/14.0.1

URL:
  <http://savannah.gnu.org/bugs/?37051>

                 Summary: define-syntax does not work when included
                 Project: Kawa
            Submitted by: None
            Submitted on: Wed 08 Aug 2012 12:34:36 AM UTC
                Category: None
                Severity: 3 - Normal
              Item Group: Unexpected result
                  Status: None
                 Privacy: Public
             Assigned to: None
             Open/Closed: Open
         Discussion Lock: Any

    _______________________________________________________

Details:

I have two files define-syntax.scm and define-syntax-main.scm. The latter just
includes the former.  The former works well but the latter does not.

$ cat define-syntax.scm
(define-syntax define-rec
   (syntax-rules ()
      ((_ rec e ...) (define-rec0 rec (e ...)))))

(define-syntax define-rec0
  (lambda (x)
    (syntax-case x ()
      ((k rec flds)
        (datum->syntax #'k
          (let* ((recnm (syntax->datum #'rec))
                 (recnmstr (symbol->string recnm))
                 (fldlist (syntax->datum #'flds)))
            (append
              `(define-record-type
                 ,recnm
                 ,(cons (string->symbol (string-append "make-" recnmstr))
                        fldlist)
                 ,(string->symbol (string-append recnmstr "?")))
              (let loop ((src fldlist) (out '()))
                (cond
                  ((null? src) (reverse out))
                  (#t
                    (let* ((fldnm (car src))
                           (fldnmstr (symbol->string fldnm))
                           (getter
                             (string->symbol
                               (string-append
                                  recnmstr "." fldnmstr "-ref")))
                           (setter
                             (string->symbol
                               (string-append
                                  recnmstr "." fldnmstr "-set!"))))
                         (loop (cdr src) (cons (list fldnm getter setter)
out)))))))))))))


(define-rec rec1 fld1 fld2 fld3)
(define a (make-rec1 0 0 0))
(display a)(newline)
(rec1.fld2-set! a 999)
(display (rec1.fld2-ref a))(newline)
$ cat define-syntax-main.scm
(include "define-syntax.scm")
$ java kawa.repl --script define-syntax.scm
address@hidden
999
$ java kawa.repl --script define-syntax-main.scm
define-syntax.scm:37:11: warning - no declaration seen for make-rec1
define-syntax.scm:39:1: warning - no declaration seen for rec1.fld2-set!
define-syntax.scm:40:10: warning - no declaration seen for rec1.fld2-ref
define-syntax.scm:37:11: unbound location make-rec1
        at gnu.mapping.SharedLocation.get(SharedLocation.java:22)
        at gnu.mapping.ThreadLocation.get(ThreadLocation.java:105)
        at atInteractiveLevel$1.run(define-syntax-main.scm:10002)
        at gnu.expr.ModuleExp.evalModule2(ModuleExp.java:309)
        at gnu.expr.ModuleExp.evalModule(ModuleExp.java:210)
        at kawa.Shell.run(Shell.java:279)
        at kawa.Shell.runFile(Shell.java:492)
        at kawa.Shell.runFileOrClass(Shell.java:426)
        at kawa.repl.processArgs(repl.java:274)
        at kawa.repl.main(repl.java:870)






    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/bugs/?37051>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/




reply via email to

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