[Top][All Lists]

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

[Chicken-janitors] #717: args egg does not call option body for missing

From: Chicken Trac
Subject: [Chicken-janitors] #717: args egg does not call option body for missing args
Date: Tue, 18 Oct 2011 15:15:31 -0000

#717: args egg does not call option body for missing args
 Reporter:  zbigniew           |       Owner:  zbigniew
     Type:  defect             |      Status:  new     
 Priority:  not urgent at all  |   Milestone:  4.8.0   
Component:  extensions         |     Version:  4.7.x   
 Keywords:  args command-line  |  
 User alanh reports that for options with required arguments, the option
 processor body is not called with ARG #f when the argument is missing.

 (use args)
 (define opts (list (args:make-option (a apple) #:required "..."
                                      (cond ((not arg) (error

 (receive (options operands) (args:parse (command-line-arguments) opts)
          (print "-- never should have gotten here on `test.scm -a'"))

 This was in fact the intended behavior -- when the arg is missing, the
 option is simply treated as not present on the command line, so you can
 handle it like you would any other missing option.  For example

 (receive (options operands) (args:parse (command-line-arguments) opts)
          (unless (assq 'apple options) (error "Missing option -a"))
          (print "-- never should have gotten here on `test.scm -a'"))

 The rationale is that if the option is formatted invalidly, the program
 should just revert to the default value for the option.

 It's possible to change this behavior, but note that missing optional and
 required arguments can't be detected unless they're absolutely last on the
 command-line, as SRFI 37 doesn't distinguish options from arguments (e.g.
 by using initial dash).  So the utility of this change would be very

Ticket URL: <>
Chicken Scheme <>
Chicken Scheme is a compiler for the Scheme programming language.

reply via email to

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