This is the mail archive of the guile@cygnus.com mailing list for the guile project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Optional Arguments (was Re: CVS script)


> Another concern was that DSSSL (and, as I've since learned, MIT
> Scheme) use special #!optional, #!key and #!rest keywords.

And Kawa, and Bigloo, and maybe others.

> Since #! _must_ be used as a block comment specifier at least at the
> start of scripts,

Another solution is to steal scsh's "meta-arg" idea:

If a command-line argument is \, then Guile read the *second*
line of input, and replaces the \ the the arguments found there.
Thus if foo starts out with:

	#!/usr/local/bin/guile \
	-e main -g
	(define (main ...) ...)

and is invoked as:
	foo a b c
then guile would be invoked as if called by:

	/usr/local/bin/guile -e main -g foo a b c

(I don't know the actual arguments supported by Guile, so ignore those.)

This avoids any hackish syntax rules for #! - rather the \ argument
is defined to cause it to skip the first line, process the second
line for command arguments, and then evaluate the remainder of the file.

I also see nothing "hackish" in defining a special meaning for #!/
- it is nothing fundamentally uglier than the difference between
#f and #\f.

	--Per Bothner
Cygnus Solutions     bothner@cygnus.com     http://www.cygnus.com/~bothner