Opened 12 years ago
Closed 12 years ago
#891 closed defect (fixed)
args egg: can't use an option called "name"
Reported by: | dreamtime | Owned by: | Jim Ursetto |
---|---|---|---|
Priority: | major | Milestone: | |
Component: | extensions | Version: | 4.7.x |
Keywords: | Cc: | ||
Estimated difficulty: |
Description
When using the args egg, trying to use an option called "name" fails because of a conflict with the args egg's own internal "name" variable.
From the args egg documentation: "BODY is an option-processor as defined in SRFI 37, and has access to the variables OPT (the current #<option>), NAME (the option name) and ARG (argument value or #f)."
At line 12 in the code example given below, everything works as intended, with the "name" variable being set to "foo" when the program is called as: ./myprogram.csi --name=foo
But after line 19, the "name" variable is empty again.
If the "name" variable is changed from "name" to anything else, like "xyz", it works.
01 (define name "") 02 03 ... 04 05 (define opts 06 (list (args:make-option 07 ... 08 (args:make-option 09 (n name) 10 (required: "NAME") 11 "description of this option goes here" 12 (set! name arg)) 13 ...) 14 15 (define (get-args) 16 (receive (options operands) 17 (args:parse (command-line-arguments) 18 opts 19 #:unrecognized-proc unrecognized-option) 20 (check-args options operands) 21 (values name foo bar baz)))
Change History (2)
comment:1 Changed 12 years ago by
Milestone: | 4.8.0 |
---|---|
Owner: | set to Jim Ursetto |
Status: | new → assigned |
comment:2 Changed 12 years ago by
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
Looks like the problem was indeed with the global variable called "name". Renaming it to "my-name" works, while still allowing a command line option called "name".
The
args:make-option
macro is unhygienic by design. This is documented:I'll leave it to Jim to decide whether close this ticket "invalid" or to come up with an alternative, hygienic, macro.