Arc Forumnew | comments | leaders | submitlogin
22 points by vincenz 5931 days ago | link | parent

Yes, quite easily, just make a new script like this:

ar.sh:

    #! /bin/sh
    #|
    exec mzscheme -fmv "$0" ${1+"$@"}
    |#
    (require mzscheme)
    (load "ac.scm") 
    (require "brackets.scm")
    (use-bracket-readtable)
    (aload "arc.arc")
    (aload "libs.arc")
    (aload (car (vector->list (current-command-line-arguments))))
main.arc:

    (whilet line (readline)
      (prn line))
shell:

    chmod +x ar.sh
    ar.sh main.arc


2 points by kens 5931 days ago | link

Thank you! That's hugely helpful! I have to say, though, that 11 lines of boilerplate kind of obliterates Arc's conciseness advantage in the Arc Challenge :-)

-----

2 points by jfm3 5931 days ago | link

Not really, the Arc Challenge specifically discounts code for setting up libraries. All the script is doing is setting up libraries and loading your code.

-----

1 point by shader 5555 days ago | link

Is there a way to execute a script that a) runs some arc or scheme code (specifically "(thread (asv))" or similar) and then b) starts the repl? Do I just change your main.arc to run the arc code I want, and then call ($ (tl))?

-----

1 point by laughingboy 5928 days ago | link

This works great, but what exactly does `"$0" ${1+"$@"}` mean? I'm not a keen shell scripter.

-----

4 points by bayareaguy 5928 days ago | link

This is the common sh shell idiom to properly pass the original command line to the program being invoked.

"$0" expands to the program name ("ar.sh" in his example).

${1+"$@"} is conditional:

if $1 (the first positional parameter) is unset it expands to nothing.

however if $1 is set, it expands to "$@", which in turn expands to all the parameters, each one quoted as a separate word.

-----

1 point by laughingboy 5928 days ago | link

Thank you.

-----

1 point by byronsalty 5913 days ago | link

I'm wondering about this #| .. |# syntax. Never seen that before.

-----

2 points by cadaver 5913 days ago | link

It's the scheme way to write multiline comments (possibly other lisps?). It's specified in the R6RS.

-----

1 point by kennytilton 5913 days ago | link

Also Common Lisp, and this reminds me that this is something I missed when working on some Arc code.

-----

2 points by cadaver 5913 days ago | link

#| ... |# works in Arc too. Though whether by design or because mzscheme supports it, I don't know.

-----

1 point by kennytilton 5913 days ago | link

Doh! :)

-----