Comment 1 for bug 159776

Revision history for this message
Abdulaziz Ghuloum (aghuloum) wrote : Re: [Bug 159776] Enabling "--r6rs-script" changes behavior of "(command-line)"

On Nov 3, 2007, at 1:23 PM, Michael D. Adams wrote:

> Public bug reported:
>
> When "--r6rs-script" is off, (command-line) does not include the
> script
> name, but when "--r6rs-script" is on, it does include the script name.
> This behavior is inconsistent. The behavior when "--r6rs-script" is
> understandable/necessary given that there might actually be multiple
> files loaded. My recommendation is that the "on" behavior be
> changed to
> match the "off" behavior.

The behavior of command-line for r6rs-scripts (script-name followed by
arguments) is consistent with R6RS, so it won't change.

There is a yet-to-be-documented "--script" flag described as follows:

   $ ikarus init-files ... --script script-file arguments ...

   Each of the init-files are loaded, one by one, into the interaction
   environment, followed by loading the script-file. The interaction
   environment initially contains all the bindings exported from the
   (ikarus) library. The value of calling the command-line procedure
   is a list containing the name of script-file and the arguments.

So, basically, when invoking ikarus as a script interpreter, you
get the script name. When ikarus is used interactively, there is
no script name, but you do get the option of adding whatever
arguments you want after the -- flag.

Example:

Suppose a.ss contains the one line:
   (display "Hi, I'm A\n")

and suppose that b.ss contains the following 3 lines:
   (display "Hello, I'm B\n")
   (write (command-line))
   (newline)

calling:
     ikarus a.ss --script b.ss x y z
produces:
   Hi, I'm A
   Hello, I'm B
   ("b.ss" "x" "y" "z")

The reason I didn't add a.ss to the command-line is that I take
a.ss is be an argument to ikarus, not an argument to your script.
So, ikarus has three modes: r6rs-script, script, and interactive.
The scripting modes are consistent. The interactive mode has no
script, only init-files, which ikarus consumes and drops from the
command line.

How does this sound?

Aziz,,,