Arc Forumnew | comments | leaders | submitlogin
DrRacket(Libs) and Arc
2 points by ChristophRe 3660 days ago | 13 comments
I have a question:

Can I use Arc in the DrRacket IDE and can I use a racket/draw library in Arc or any other Racket library?



2 points by ChristophRe 3654 days ago | link

I wanted create a frame with in Racket

; Make a frame by instantiating the frame% class (define frame (new frame% [label "Example"]))

but because of Arc special syntax like [+ _ 1] this does not work, because the interpreter translage [label "example"] into a anonymous function.

Anyone who know how to solve this?

-----

2 points by Pauan 3654 days ago | link

I just fixed a bug in Arc/Nu, so now you can do this:

  (%:require racket/class)
  (%:require racket/gui/base)

  (= frame (%:new frame% (label "Example")))
Notice that you can use () rather than [], because in Racket the syntax reader converts [] into ().

You need to require "racket/class" because Arc/Nu only requires "racket/base", rather than all of "racket".

-----

2 points by ChristophRe 3654 days ago | link

in the end it would be nicer to have an Arc library that wraps the underlying gui racket library in the spirit of Arc. Arc is much simpler than scheme code. I does not like complicated syntax. I also does not like OO and classes of racket. It is the wrong way. Hashtable like in Javascript and writing your own OO-like library is much more flexible.

-----

1 point by akkartik 3654 days ago | link

You should build it :) Doesn't have to be complete at the start, just use it for a certain program and try to think of a cleaner way to express what you build. Then come ask us for help.

-----

2 points by ChristophRe 3654 days ago | link

Thank you very much. I assume that I could use another syntax for [...] like in Arc. But I did not find it. So often it is better to ask people you has better scheme background. I am not grown up with Lisp stuff.

-----

1 point by akkartik 3660 days ago | link

Arc3.1 and Anarki are built on the outdated mzscheme language. But you might be able to use Pauan's Arc/Nu: https://github.com/arclanguage/arc-nu. We'd love to hear your experiences if you try it out.

-----

1 point by jsgrahamus 3659 days ago | link

Can anyone refer me to the method of accessing the underlying mzscheme or racket functions?

Thanks, Steve

-----

1 point by akkartik 3659 days ago | link

You mean in Nu? % on Nu is like $ on anarki. Does that answer your question?

-----

3 points by jsgrahamus 3658 days ago | link

I didn't specify. Could you give an example in each of them? Thanks, Steve

-----

2 points by akkartik 3658 days ago | link

To call racket functions in anarki:

  arc> ($.pair? '(1))
  #t
In Nu:

  > (%.pair? '(1))
  #t

-----

2 points by jsgrahamus 3658 days ago | link

Thanks, Akkartik. Is there a way to do such from arc itself?

-----

1 point by akkartik 3658 days ago | link

No, you'll have to add it. The simplest way to do this is probably aw's original hack: http://hacks.catdancer.ws/ac.html

You'll need to add one line to ac.scm, and then:

  arc> (ac-scheme.pair? '(1))
  #t
Feel free to rename ac-scheme to $ or % if you think you'll use it often enough.

If you start using this you'll start finding the need for some of the other functions in that link, which transform data back and forth to the way racket or arc likes it. Come back and ask us more questions when you run into errors like this:

  arc> (ac-scheme.length '(1 2 3))
  Error: "length: contract violation\n  expected: list?\n  given: '(1 2 3 . nil)"

-----

3 points by Pauan 3656 days ago | link

I would just like to point out that Arc/Nu is fully compatible with Arc 3.1, and it doesn't need conversions between Racket and Arc, so it's the easiest way to deal with Racket in Arc programs.

-----