[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: cmdline.ss library in PLT

This page is part of the web mail archives of SRFI 37 from before July 7th, 2015. The new archives for SRFI 37 contain all messages, not just those from before July 7th, 2015.



At Tue, 24 Sep 2002 12:49:10 -0400 (EDT), Anthony Carrico wrote:
> I have briefly reviewed the cmdline.ss documentation. Let me say up front
> that there are a lot of ways to this job, and I doubt any way is perfect.
> My goal with args-fold was to provide a useful, generic, and flexible
> interface to the Posix/GNU guidelines in "the spirit of Scheme".
> Arguments could be made about my design choices from two directions: about
> the programmer's interface, about the user's interface.
> 
> Here are my notes about cmdline.ss:
> 
> 1. Cmdline seems to have a mandatory builtin help system. In args-fold, a
> help option in handled by the programmer like any other option.

yes, we found that making the --help option a built-in saves a lot on
mantainence. It's much harder to forget to update the help docs in
their current form.

> 2. Cmdline seems to support more than one argument per option. Args-fold
> supports 0 or 1 arguments per option, following the lead of POSIX/GNU
> guidelines.

This turns out to be useful for many things. One I use a lot in plt
scheme is loading a library:

  mzscheme -L errortrace.ss errortrace -r myscript.ss

is a convient way to debug my script: the first three arguments specify
that the debugging code is loaded before the script is executed. The -L
flag means "take the next two arguments and pass them to `require' as a
library". In this case:

  (require (lib "errortrace.ss" "errortrace"))

Without multiple argument commandline options, this becomes tricky.

Does the GNU/POSIX spec give a rationale for only allowing single
arguments?

> 3. At first, I thought it would be possible to implement cmdline in terms
> of args-fold, but I believe the cmdline interface requires a
> "procedure-arity" implementation. This is a clever trick that takes
> advantage plt-scheme, but I think it also prevents cmdline from being
> implemented on most other Scheme systems.

Yes, that's right. However, there is room for an additional optional
number that would specify the number of arguments to the flag. In plt
scheme, we could have the default be the arity of the procedure. On
other systems, you wouldn't be allowed to leave it off.

Of course, point 2 also prevents implementing cmdline.ss in terms of
args-fold.

Robby