
Dynamically running Records1 code causes the following error:
10215 % racket driver.rkt
3
3
cannot instantiate `racket/gui/base' a second time in the same process
context...:
/MyApplications/dev/lisp/Racket/share/pkgs/gui-lib/mred/private/wx/common/once.rkt: [running body]
/MyApplications/dev/lisp/Racket/share/pkgs/gui-lib/mred/private/wx/common/utils.rkt: [traversing imports]
/MyApplications/dev/lisp/Racket/share/pkgs/gui-lib/mred/private/wx/cocoa/utils.rkt: [traversing imports]
/MyApplications/dev/lisp/Racket/share/pkgs/gui-lib/mred/private/wx/cocoa/pool.rkt: [traversing imports]
/MyApplications/dev/lisp/Racket/share/pkgs/gui-lib/mred/private/wx/cocoa/init.rkt: [traversing imports]
/MyApplications/dev/lisp/Racket/share/pkgs/gui-lib/mred/private/wx/cocoa/platform.rkt: [traversing imports]
/MyApplications/dev/lisp/Racket/share/pkgs/gui-lib/mred/private/wx/platform.rkt: [running body]
/MyApplications/dev/lisp/Racket/share/pkgs/gui-lib/mred/private/kernel.rkt: [traversing imports]
/MyApplications/dev/lisp/Racket/share/pkgs/gui-lib/mred/private/mred.rkt: [traversing imports]
/MyApplications/dev/lisp/Racket/share/pkgs/gui-lib/mred/mred.rkt: [traversing imports]
/MyApplications/dev/lisp/Racket/share/pkgs/gui-lib/mred/main.rkt: [traversing imports]
/MyApplications/dev/lisp/Racket/share/pkgs/gui-lib/racket/gui/base.rkt: [traversing imports]
/MyApplications/dev/lisp/Racket/share/pkgs/redex-gui-lib/redex/private/stepper.rkt: [traversing imports]
/MyApplications/dev/lisp/Racket/share/pkgs/redex-gui-lib/redex/gui.rkt: [traversing imports]
/MyApplications/dev/lisp/Racket/share/pkgs/redex-gui-lib/redex/main.rkt: [traversing imports]
/Users/ryan/Library/Racket/6.9/pkgs/racket-school-mystery-languages/private/mystery.rkt: [traversing imports]
...
This is just down in the terminal. No possibility of a stepper. Is there some way around this?

I’m SOOO close

(define (compare src lang1 lang2)
(define s1 (run-with-lang (open-input-string src) lang1))
(define s2 (run-with-lang (open-input-string src) lang2))
(equal? s1 s2))
(time ; works fine
(for ([i (in-range 10)])
(compare "(+ 1 2)" 'racket 'RecImpl)))
(time ; blows up
(for/list ([i (in-range 1)])
(compare "(+ 1 2)" 'racket 'RacketSchool/Records1)))

@robby would you be open to making (require redex)
be more lightweight? (require redex/stepper)
or (require redex/gui)
to pull in the rest?

(happy to do the work)

YES!

@florence Because of the above I had to switch to using a shared namespace:
(define-namespace-anchor this-namespace-anchor)
(define ns (namespace-anchor->namespace this-namespace-anchor))

@zenspider To avoid multiple instantiations of racket/gui/base
, you can use make-gui-namespace
instead of make-namespace
. The sandbox uses racket/gui/dynamic
to decide which to use (and there are various dependency and historical reasons behind why it isn’t built-in).

@zenspider the redex module is already broken up and you can require redex/reduction-semantics for just the basics. I don’t think we can change what the redex module exports anymore.

@mflatt that’ll probably fix my original code right up. There are only 3–4 mentions of this on google (one was @florence and all(?) were to @greg on racket-mode iirc). If make-namespace
made mention of it some of this could probably be avoided.
@robby nod makes sense. The problem (I think) is that everything is requiring redex straight and my module instantiator was getting beat up. But I think that’s probably solved now.

even if I leave the code as-is… since the best I can do with dynamic-require
is grab the output, I don’t think my namespace-anchor route can get beat up THAT badly. I can’t even see provides because of the fixed module boundary

Single iteration of (+ 1 2)
'read+eval
cpu time: 12 real time: 13 gc time: 0
'racket
cpu time: 28 real time: 28 gc time: 0
'RecImpl
cpu time: 42 real time: 42 gc time: 25
'Records1
cpu time: 1012 real time: 1011 gc time: 268
`

Records1’s interpreter is actually driving entirely through redex

Farewell SLC. Thank you everyone for making School fun :)

How am I supposed to write this?
(define-syntax (function stx)
(syntax-parse stx
[(_ id:id)
#'(if (identifier-binding #'id)
(if (procedure? id) ; blows up here for missing
id
(or 'ERROR (error 'function "~v is not a function" id)))
`(function ,'id)
)]))
(define x 42)
(define y (fn 'y (lambda (x) 42)))
(function x) ; 'ERROR
(function y) ; (function y)
(function missing) ; missing: unbound identifier in module

dispatch elsewhere for the procedure?
part?

also was looking at syntax-let…

I got everything working! On iteration 392 it found an equivalent to what @sorawee found!!

:slightly_smiling_face:

Not sure I agree with the error but I’ll fix it anyway. Thank you for finding and reporting it to me! It got me moving on making this verification framework.