Arc Forumnew | comments | leaders | submitlogin
Using racket libraries in Arc
2 points by forwardslash 4145 days ago | 5 comments
Has anyone tried using libraries (such as those in Planet) with Arc? I've tried xdefing functions but it doesn't seem to work. I'd love to be able to use existing mongodb client libraries in particular instead of implementing them myself (I'm not even sure where to start with socket connection management).


3 points by rocketnia 4144 days ago | link

Here's something that worked for me in Arc 3.1 and Anarki.

Add this toward the bottom of ac.scm so that it can use the xdef syntax defined earlier in the file:

  (require racket/class)
  (require racket/gui/base)
  
  (define frame
    (new frame%
      (label "Example")
      (min-width 200)
      (min-height 200)))
  (xdef frame frame)
  (xdef dynamic-send dynamic-send)
Now from the Arc REPL, you can run this command:

  (dynamic-send frame 'show #t)
Since 'dynamic-send is provided by the racket/class module, doing 'xdef with libraries should work.

Some notes:

If ac.scm used the racket module instead of the mzscheme module, it would have access to all the racket/class bindings to begin with, and then I suppose I'd use a different example. ^_^

In Arc 3.1, the GUI that appears is unresponsive for me. If I Ctrl-C once in the REPL, the REPL stops processing input but the GUI becomes responsive. If I do it again, the GUI closes. I fumbled with threads trying to make the REPL and the GUI work concurrently, but nothing worked, and I've given up for now.

In Anarki, the GUI that appears is unresponsive, but doing Ctrl-C in the REPL exits Racket entirely, including the GUI. Again, my attempts to use threads haven't helped.

-----

3 points by rocketnia 4145 days ago | link

I thought it was pretty easy to use Racket libraries (except for macros). When I wrote Anarki's libs/ns.arc, I had trouble, but not this kind of trouble. However, I guess I never really tried to add imports to ac.scm. What do you mean by "it doesn't seem to work"?

-----

2 points by forwardslash 4145 days ago | link

It could be that I'm working off a codebase that is missing some functions which Anarki uses to do that (I'm going through and comparing them now). When I try simply xdefing functions from libraries I get errors like "Expected 0 arguments with optional arguments X Y Z and got (args)"

I'm thinking of trying to follow how lib/json.ss integrates itself: https://github.com/arclanguage/anarki/blob/master/lib/json.s...

or perhaps wrapping things in a module.

-----

2 points by akkartik 4145 days ago | link

Can you give us a simple, reproducible set of directions based on say arc3.1?

-----

2 points by akkartik 4145 days ago | link

I haven't tried this. I wonder if it's because arc's running on the mzscheme language.

One suggestion: try https://github.com/arclanguage/arc-nu, the clean racket-only repo. I've not played with it much, though.

-----