Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Internal define inserted by a macro is not recognized #221

Closed
shirok opened this Issue Aug 6, 2016 · 0 comments

Comments

Projects
None yet
1 participant
@shirok
Copy link
Owner

shirok commented Aug 6, 2016

From http://practical-scheme.net/wiliki/wiliki.cgi?Gauche%3ABugs#H-2pth75cnp87ol

(define-library (test-lib)
  (export my-define)
  (import (scheme base))
  (begin
    (define-syntax my-define
      (syntax-rules ()
        ((_ var expr)
         (begin
           (define var expr)
           var))))
    ))
そして、以下のようにこのライブラリを使うプログラムを作成します。

(import (scheme base))
(import (only (gauche base) add-load-path use print))
(add-load-path "." :relative)
(import (test-lib))
;(use test-mod)

(define (f)
  (my-define x 100)
  (+ x 1))

(print (f))
このプログラムを実行すると、以下のエラーが出ます。

*** ERROR: syntax-error: the form can appear only in the toplevel: (#<identifier
 test-lib##<identifier test-lib#define.2d13860>.2d13500> x 100)
    While compiling "./test.scm" at line 7: (define (f) (my-define x 100) (+ x 1
))
    While loading "./test.scm" at line 9

@shirok shirok closed this in a105612 May 2, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.