[Top][All Lists]

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

Re: Bug in getopt-long?

From: Daniel Skarda
Subject: Re: Bug in getopt-long?
Date: 02 Aug 2001 11:32:34 +0000
User-agent: Gnus/5.0806 (Gnus v5.8.6) Emacs/20.6

>      (define (test1 . args)
>        (getopt-long  args
>        `((test (value #t)
>                  (predicate ,(lambda (x) (string-match "^[0-9]+$" x)))))))
>      (test1 "foo" "bar")
>       [error] option predicate failed: test              !!! HUH !!!
>      Huh! It looks like that presence of `predicate' implies that
>    argument is required. I have not studied (ice-9 getopt-long) module
>    sources but this strange behaviour is not documented (not even
>    expected :-)
> actually this looks ok to me -- `test' is specified w/ `(value #t)',
> meaning that it is invalid to not have an associated argument.  the
> error message could be more clear, however (something along the lines of
> "missing argument: test").

 I think that getopt-long arguments should be independent and one should not
 imply another. If I had needed to make '--test' argument mandatory, I would
 have wrote '(required #t).

 There are a lot of optional arguments, which you would like to check for
 correctness (using `file-exist?' - for example) and it does not make sense to
 check optional arguments in different way than mandatory arguments.

 Maybe we also can improve getopt-long error reporting by adding one option -
 predicate-failed - something like this...

   (getopt-long args
            (value #t) 
            (predicate ,file-exist?) 
            (preciade-failed ,(lambda (x) (%% "Can not find file ~S" x))))))

 ... because 'option predicate failed' is not too informative :)
 (I use @@ as a shortcut for (apply format #t args) and %% for (apply format #f 


reply via email to

[Prev in Thread] Current Thread [Next in Thread]