Subject: Re: Problems with my interpreter
From: rpw3@rigden.engr.sgi.com (Rob Warnock)
Date: 27 Apr 2001 02:43:12 GMT
Newsgroups: comp.lang.scheme
Message-ID: <9camc0$3ghqs$1@fido.engr.sgi.com>
<mariom@newknow.com> wrote, re MIT Scheme:
+---------------
| The problem is that i can just use it at command line as with a python
| interactive mode, but i cant interprete it as a solely file, that is i 
| cant do something like:    scheme my_program.scm
| Do you know something about another tool which solves my problem?
+---------------

MzScheme (part of DrScheme <URL:http://www.drscheme.org/>)
lets you do that:

    % cat foo.scm
    (display "Hello, world!")
    (newline)
    % mzscheme -r foo.scm
    Hello, world!
    % 

And if you just want to pre-load the file, but still go into
interactive mode, user the "-f" option:

    % mzscheme -f foo.scm
    Welcome to MzScheme version 101, Copyright (c) 1995-99 PLT (Matthew Flatt)
    Hello, world!
    > (* 2 3)
    6
    > ^D

Finally, under Unix it follows the "#!" convention[*]:

    % cat foo
    #!/usr/local/bin/mzscheme -r
    (display "Hello, world!")
    (newline)
    % foo
    Hello, world!
    % 

In the latter case, remaining command-line arguments are available
in the global variable "argv" (a vector of strings):

    % cat foo2
    #!/usr/local/bin/mzscheme -r
    (display "Hello, world!")
    (newline)
    (display "Here are my args: ")
    (write argv)
    (newline)
    % foo2
    Hello, world!
    Here are my args: #0()
    % foo2 bar baz -q gorp "some spaces here"
    Hello, world!
    Here are my args: #5("bar" "baz" "-q" "gorp" "some spaces here")
    % 


-Rob

-----
Rob Warnock, 31-2-510		rpw3@sgi.com
SGI Network Engineering		<URL:http://reality.sgi.com/rpw3/>
1600 Amphitheatre Pkwy.		Phone: 650-933-1673
Mountain View, CA  94043	PP-ASEL-IA