Closed GoogleCodeExporter closed 9 years ago
Either parse twice or delay actions. But I don't want the
command-line processing to be more complicated than
needed.
Did you have a specific use-case for this?
Original comment by alexsh...@gmail.com
on 19 Jun 2013 at 12:08
Module foo.bar defines a main procedure, and I call it with:
chibi-scheme -m foo.bar -e '(main)' -- arg1 arg2 arg3 ...
Alternatively, module foo.bar implements an implicit main procedure in a begin
clause, and I invoke it with
chibi-scheme -m foo.bar -- arg1 arg2 arg3 ...
I guess there are alternatives, but these seem natural to me, and I was very
surprised that they didn't work.
Original comment by a...@astro.unam.mx
on 19 Jun 2013 at 1:38
This is similar to Python. I was debating whether it was worthwhile, since
it encourages bloating modules with mains. But it occurred to me that the
-r option used for SRFI-22 should already handle this, and it was more of
a bug that it didn't (there's no reason to require the script).
So you can write:
chibi-scheme -mfoo.bar -rmain -- arg1 arg2 arg3 ...
which is the same as
chibi-scheme -mfoo.bar -r -- arg1 arg2 arg3 ...
which is the same as
chibi-scheme -e'(define (main) <inline from foo.bar>)' -r -- arg1 arg2 arg3 ...
Note that if you do want to specify a name other than main,
there must be no space after -r.
How's that?
Original comment by alexsh...@gmail.com
on 19 Jun 2013 at 2:23
OK, I can use -r to work around this problem. Thanks.
However, if I understand correctly, (command-line) will return #f prior to
calling the main procedure named by the -r option and will return a list of the
specified arguments after calling the main procedure named by the -r option. I
think the principle of least surprise requires that (command-line) give the
same result no matter when it is called.
I used my original approach since defining a main in a module (or using
implicit code in a begin) and using (command-line) to get the arguments seemed
to be the safest way in R7RS-small Scheme to do this sort of thing. SRFI-22 is
not part of R7RS-small Scheme.
By the way, the man page mentions -r but not -r<name> and "chibi-scheme --help"
doesn't mention -r. I understand that the documentation for head is not always
completely up-to-date.
Original comment by a...@astro.unam.mx
on 19 Jun 2013 at 3:20
The only safe R7RS approach is to write a program. Once you're
talking about impl-specific options like -e nothing is portable.
I had updated chibi-scheme -h to mention -r. Specifying a name
other than main was not officially supported. I'll try to improve
docs before the release.
Original comment by alexsh...@gmail.com
on 19 Jun 2013 at 9:40
Yes, you're right that although my module code conforms to the draft R7RS, the
way I invoke it does not. Thanks.
Alan
Original comment by a...@astro.unam.mx
on 20 Jun 2013 at 6:25
Original issue reported on code.google.com by
a...@astro.unam.mx
on 19 Jun 2013 at 5:19