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

[plt-scheme] The same macro problem

Since there was no reply to the last message I sent, I tried some
stuff myself.  Again, I think that a general separation between the
syntax-processing environment and the normal one is generally a good
thing, and as far as writing "standalone" applications (ones with no
dynamic evaluation), nothing more is ever needed.  However, when
playing with some interactive environment on top of Scheme, it might
be necessary to share information between the two environments.  One
example is the many macros in my Swindle thing, some do exactly that.

I have tried things like evaluating user code in the syntax
environment which didn't work since it seems like the syntax
environment is not just a different namespace (I tried digging through
the C source but got nowhere):

  Welcome to MzScheme version 200alpha19, Copyright (c) 1995-2002 PLT
  > (define-syntax (foo stx)
      (syntax-case stx ()
        ((_ var val) (with-syntax ((exp (syntax (define var val))))
                       (eval (syntax exp))
                       (syntax exp)))))
  > (foo x 1)
  > x
  > (define-syntax (bar stx) (printf ">>> %s\n" x) (syntax 1))
  > (bar)
  reference to undefined identifier: x

I also tried a module -- baring in mind the other problem of not being
able to create temporary small modules for such things, but it still
doesn't work since the module will generate a new value for each layer
making it impossible to share dynamic information:

  Welcome to MzScheme version 200alpha19, Copyright (c) 1995-2002 PLT
  > (module a mzscheme (define aa (make-parameter 123)) (provide aa))
  > (require a)
  > (require-for-syntax a)
  > (define-syntax (foo stx) (aa 999) (syntax 1))
  > (foo)
  > (define-syntax (bar stx) (printf ">>> ~s\n" (aa)) (syntax 1))
  > (bar)
  >>> 999
  > (aa)

I believe that this is a serious problem since it eliminates some of
the dynamic aspects of the language, which, IMO, is the greatest thing
about Scheme.  Sorry sounding like ranting, I would love to suggest a
solution if I could get something to work...

          ((lambda (x) (x x)) (lambda (x) (x x)))          Eli Barzilay:
                  http://www.barzilay.org/                 Maze is Life!