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] |
russell.mcmanus@gs.com writes: > > Please try this out, suggestions welcome. > > ;;; (getopt-long '("my-program" "-vk" "/tmp" "foo1" "--x-includes=/usr/include" > ;;; "--rnet-server=lamprod" "--" "-fred" "foo2" "foo3") > ;;; `((lockfile-dir required > ;;; value required > ;;; single-char k > ;;; predicate ,file-is-directory?) > ;;; (verbose not required single-char v value not allowed) > ;;; (x-includes single-char x) > ;;; (rnet-server single-char y predicate ,string?))) > ;;; > I haven't looked in detail, but I have to admit I think the syntax for option specifiers is a bit odd for my tastes. I think it is more Schemely to use parentheses and values of various types as the syntax, rather than a bunch of words in one long list. I'd rather see option specs based on alists, perhaps like this: `(((long "lockfile-dir") (required #t) (value 'required) (short #\k) (predicate ,file-is-directory?)) ((long "verbose") (required #f) (short #\v) (value #f)) ((long "x-includes") (short #\x)) ((long "rnet-server") (short #\y) (predicate ,string?))) This has the added advantage that it's easy to parse, in fact, other than adding default values and sanity checking, it hardly needs to be parsed at all. > (define-module (gs getopt-long) > :use-module (ice-9 slib)) > (require 'struct) > (require 'common-list-functions) > It would be nicer not to require slib, especially for things intended to ship with Guile. I think the common-list-functions stuff is provided by (ice-9 common-list). As for the struct stuff, it would be nicer if either the Guile stock record stuff or a list-based implementation or something were used. Other than that, it looks pretty nice overall. - Maciej