Summary
getopt-long (value #f) inconsistent with documentation
Metadata
- Id: e562f483bee16b3a45455f2252bf254376c60cf2
- Trac id: 1289
- Type: defect
- Reporter: nxg
- Owner:
- Cc:
- Status: closed
- Component: extensions
- Estimated difficulty:
- Resolution: fixed
- Priority: major
- Milestone: someday
- Version: 4.10.x
- Changetime: 2016-08-25 20:31:58 UTC
- Created: 2016-05-26 18:30:13 UTC
- Keywords: getopt-long
Description
The documentation for `getopt-long` says that
(value FLAG [[(PROPERTY|VALUE) ...]]) If FLAG is #t, the option requires a value;...
and
(predicate FUNC) If the option accepts a value (i.e. you specified (value #t) for this option)...
These would seem to indicate that `(value #t (predicate ,string))` would be acceptable, but the following program fails:
(use getopt-long)
(define grammar
`((test (single-char #\t)
(value #t ;(required "REQ")
(predicate ,string?)))))
(write
(getopt-long '("my-prog" "-t" "foo")
grammar))
(newline)
Result:
% csi getopt-long-demo.scm CHICKEN (c) 2008-2015, The CHICKEN Team (c) 2000-2007, Felix L. Winkelmann Version 4.10.0 (rev b259631) macosx-unix-clang-x86-64 [ 64bit manyargs dload ptables ] compiled 2015-08-04 on yves.more-magic.net (Linux) ; loading getopt-long-demo.scm ... ; loading /Data/tools/chicken-4.10.0/lib/chicken/7/getopt-long.import.so ... ; loading /Data/tools/chicken-4.10.0/lib/chicken/7/chicken.import.so ... ; loading /Data/tools/chicken-4.10.0/lib/chicken/7/data-structures.import.so ... ; loading /Data/tools/chicken-4.10.0/lib/chicken/7/srfi-1.import.so ... ; loading /Data/tools/chicken-4.10.0/lib/chicken/7/srfi-13.import.so ... ; loading /Data/tools/chicken-4.10.0/lib/chicken/7/srfi-14.import.so ... ; loading /Data/tools/chicken-4.10.0/lib/chicken/7/matchable.import.so ... ; loading /Data/tools/chicken-4.10.0/lib/chicken/7/lolevel.import.so ... ; loading /Data/tools/chicken-4.10.0/lib/chicken/7/getopt-long.so ... ; loading /Data/tools/chicken-4.10.0/lib/chicken/7/matchable.so ... Error: invalid value specification : (#t (predicate #<procedure (string? x463)>))
Replacing the `#t` with `(required "REQ")` works as expected.
Changes and comments
[2016-05-31 21:25:53 UTC] iraikov wrote:
Thanks for reporting this issue. I have added a clarification of the semantics of the value property to the getopt-long documentation.
[2016-06-01 10:34:53 UTC] nxg wrote:
Looks good to me!
(do I close this issue or do you?)
[2016-08-25 20:31:58 UTC] sjamaan changed status from new to closed
[2016-08-25 20:31:58 UTC] sjamaan removed difficulty
[2016-08-25 20:31:58 UTC] sjamaan set resolution to fixed
[2016-08-25 20:31:58 UTC] sjamaan wrote:
Looks like it's fixed then