Use number of procedure arguments function from util-proc in command-line.
This commit is contained in:
parent
147afa3ab4
commit
c2c19c2d6a
4 changed files with 16 additions and 9 deletions
|
@ -91,7 +91,7 @@ listing.o: listing.import.scm
|
|||
listing.import.scm: $(LISTING-SOURCES)
|
||||
|
||||
UTIL-DICT-LIST-SOURCES=util-dict-list.scm testing.import.scm \
|
||||
util-tag.import.scm
|
||||
util-tag.import.scm util-proc.import.scm
|
||||
|
||||
util-dict-list.o: util-dict-list.import.scm
|
||||
util-dict-list.import.scm: $(UTIL-DICT-LIST-SOURCES)
|
||||
|
@ -113,7 +113,7 @@ ansi.o: ansi.import.scm
|
|||
ansi.import.scm: $(ANSI-SOURCES)
|
||||
|
||||
COMMAND-LINE-SOURCES=command-line.scm testing.import.scm \
|
||||
util-list.import.scm
|
||||
util-list.import.scm util-proc.import.scm
|
||||
|
||||
command-line.o: command-line.import.scm
|
||||
command-line.import.scm: $(COMMAND-LINE-SOURCES)
|
||||
|
|
|
@ -39,7 +39,8 @@
|
|||
(chicken process-context)
|
||||
(chicken format)
|
||||
util-list
|
||||
testing)
|
||||
testing
|
||||
util-proc)
|
||||
|
||||
;; Consumes given number of arguments from the list and returns the
|
||||
;; remainder of the list and a list of arguments consumed.
|
||||
|
@ -74,8 +75,7 @@
|
|||
(when (not specp)
|
||||
(error 'parse-command-line "Unknown argument" arg))
|
||||
(let* ((proc (caddr specp))
|
||||
(info (procedure-information proc))
|
||||
(nargs (- (length info) 1))
|
||||
(nargs (procedure-num-args proc))
|
||||
(aargsl (consume-args (cdr args) nargs))
|
||||
(args (car aargsl))
|
||||
(aargs (cadr aargsl)))
|
||||
|
|
|
@ -54,7 +54,8 @@
|
|||
(import scheme
|
||||
(chicken base)
|
||||
testing
|
||||
util-tag)
|
||||
util-tag
|
||||
util-proc)
|
||||
|
||||
;; Tag used for identifying list dictionaries from this module
|
||||
(define TAG-LDICT (make-tag LDICT))
|
||||
|
@ -162,9 +163,8 @@
|
|||
;; accepts more than one argument. If it accepts a third argument,
|
||||
;; index gets passed as well.
|
||||
(define (ldict-map proc ld)
|
||||
(let* ((lpi (length (procedure-information proc)))
|
||||
(both? (> lpi 2))
|
||||
(index? (> lpi 3)))
|
||||
(let ((both? ((procedure-arity>=? 2) proc))
|
||||
(index? ((procedure-arity>=? 3) proc)))
|
||||
(let loop ((pairs (ldict-pairs ld))
|
||||
(res '())
|
||||
(i 0))
|
||||
|
|
|
@ -31,6 +31,8 @@
|
|||
procedure-arity=?
|
||||
procedure-arity>=?
|
||||
procedure-arity>?
|
||||
|
||||
procedure-num-args
|
||||
)
|
||||
|
||||
(import scheme
|
||||
|
@ -72,4 +74,9 @@
|
|||
(or rest?
|
||||
(> args n))))
|
||||
|
||||
;; Returns the number of mandatory arguments
|
||||
(define (procedure-num-args proc)
|
||||
(let-values (((args rest?) (procedure-arity-info proc)))
|
||||
args))
|
||||
|
||||
)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue