Running Scheme from the command line

后端 未结 4 2181
青春惊慌失措
青春惊慌失措 2021-01-01 23:01

How do you run Scheme programs from the terminal in linux(ubuntu)? Also how to accept arguments from the command-line in a Scheme program?

Edit: Im using the DrSc

4条回答
  •  暗喜
    暗喜 (楼主)
    2021-01-01 23:20

    The DrScheme scheme implementation, and the name you use to execute it from the command line, is mzscheme. The documentation for starting a command line script is found here: Unix Scripts (PLT Scheme documentation). Use of the command line args is explained here: Command-line Parsing (PLT Scheme Documentation).

    The upshot is that you can use shebang scripts like this:

    #! /usr/bin/env mzscheme
    #lang scheme/base
    (...scheme s-exps...)
    

    or if you want more control over the command line flags for mzscheme, you need to start the script like this:

    #! /bin/sh
    #|
    exec mzscheme -cu "$0" ${1+"$@"}
    |#
    #lang scheme/base
    (...scheme s-exps...)
    

    The function you use to process command line args is command-line. You will find examples of how to use it in the article linked to by the second link.

提交回复
热议问题