Arc Forumnew | comments | leaders | submitlogin
2 points by aw 5264 days ago | link | parent

Scheme libraries can be loaded dynamically from Arc using Anarki's $ or my ac-scheme. And, using the the "file" variant of require means that PLTCOLLECTS doesn't need to be set. Thus in a fresh clone of Anarki as of this morning, with nothing uncommented:

  arc> ($ (require (file "lib/json.ss")))
  #<void>
  arc> ($ (xdef json-read json-read))
  #<procedure:json-read>
  arc> (fromstring "true" (json-read (stdin)))
  t


1 point by akkartik 5264 days ago | link

Thanks a lot.

-----

1 point by akkartik 5263 days ago | link

I decided that the json library perhaps shouldn't even be in anarki, so I've been experimenting with keeping it in my project sources. It seems useful to be able to mix arc with scheme in a project, especially for performance reasons.

Problem is, I can't do it without literally hardcoding a string literal: ($ (require (file "/path/to/json.ss")))

I've tried defining a helper function, but require must be at the top level. I've tried saying (require (file (+ dir "json.ss"))), but it seems the inside of the require form isn't lisp but some toy, bizarro universe.

This whole experience is bringing home just how much I hate the mzscheme module system. Lisp is all flowing lines; require is a brick. Just one way to use it; once you release it all it can do is sink.

Any suggestions?

-----

1 point by aw 5263 days ago | link

A macro can expand into a ($ ...) or (ac-scheme ...) form, so try

  (= json-path "/tmp/json-scheme-20050827134102/json.ss")

  (mac load-json ()
    `($ (require (file ,json-path))))

  (load-json)

-----

1 point by akkartik 5263 days ago | link

Awesome thanks!

  (mac load-scheme(f)
    `($ (require (file ,(+ ($ start-dir*) f)))))
  (load-scheme "json.ss")

-----