Arc Forumnew | comments | leaders | submitlogin
8 points by fallintothis 5576 days ago | link | parent

MzScheme has mzc, which does bytecode compilation. You can create something like standalone executables by embedding a copy of MzScheme into the module you're compiling. See http://download.plt-scheme.org/doc/372/html/mzc/ for more details.

Using some work done on Anarki (http://github.com/nex3/arc/blob/dca901c0cb59ebb533a511df3a84... and http://github.com/nex3/arc/blob/dca901c0cb59ebb533a511df3a84...), you could throw together something like:

test.arc

  (prn "Hello, world")
arc-exe-init.scm

  (module arc-exe-init mzscheme
    (provide (all-from-except mzscheme read read-syntax)))
test.arc.scm

  (module test.arc "arc-exe-init.scm"

    (require "ac.scm")
    (namespace-require "ac.scm")
    (require "brackets.scm")
    (use-bracket-readtable)

    (aload "arc.arc")
    (aload "libs.arc")

    (aload "test.arc") ; or the output of (acompile "test.arc") could work
  )
Then

  $ mzc --exe test test.arc.scm
  mzc version 360, Copyright (c) 2004-2006 PLT Scheme Inc. 
  [output to "test"]
  $ ./test
  Hello, world
The results you get hardly seem worth the effort. With this, you'd still need to distribute with some form of ac.scm et al.

  $ mv test ~/Desktop/
  $ cd ~/Desktop/
  $ ./test
  default-load-handler: cannot open input file: "~/Desktop/ac.scm" (No such file or directory; errno=2)

   === context ===
  #f::352: loop
There are probably smarter ways of compiling that don't have this hang-up, but in the end you'll still have kind of a large binary with MzScheme embedded.

If you just want the Scheme equivalent of Arc code, Arc already compiles down to Scheme. To get this compiled version (even if you can't run it directly without loading ac.scm, brackets.scm, arc.arc, and libs.arc):

  $ cat test.arc
  (prn "Hello, world")
  $ mzscheme -m -f as.scm
  Use (quit) to quit, (tl) to return here after an interrupt.
  arc> :a
  > (acompile "test.arc")
  Hello, world
  #t
  > ^D
  $ cat test.arc.scm
  (ar-funcall1 _prn "Hello, world")


4 points by thaddeus 5575 days ago | link

Not to worried about about mzscheme being embedded as it's only 24MB. This is good to know... I plan to experiment with it a little so thanks for guidance.

T.

-----