[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Looping local binding
From: |
Marco Maggi |
Subject: |
Re: Looping local binding |
Date: |
Tue, 30 Oct 2007 19:03:08 +0200 |
(define-module (doit)
#:use-module (ice-9 format)
#:use-module (ice-9 getopt-long)
#:use-module (ice-9 syncase))
(define-syntax let-numeric-options
(syntax-rules ()
((_ ?options-list (?option ...) ?body ...)
(let ((?option (string->number
(option-ref ?options-list
(quote ?option)
(number->string ?option))))
...)
?body ...))))
(define-syntax print-option
(syntax-rules ()
((_ ?option)
(format #t "~A~/= ~A~%" (quote ?option) ?option))))
(define *grammar*
'((method (value #t))
(right-bound (value #t))
(wave-number (value #t))
(subintervals (value #t))
(test-epsilon (value #t))))
(define (test args)
(let* ((options (getopt-long args *grammar*))
(method (option-ref options 'method "fundmatrix"))
(right-bound 1)
(wave-number 2)
(subintervals 3)
(test-epsilon 4)
(separator (lambda ()
(display (make-string 30 #\-))
(newline))))
(let-numeric-options options
(right-bound wave-number subintervals test-epsilon)
(separator)
(print-option method)
(print-option right-bound)
(print-option wave-number)
(print-option subintervals)
(print-option test-epsilon)
(separator))))
(test '("the-command"))
(test '("the-command" "--right-bound=123" "--subintervals=456"))
(test '("the-command" "--subintervals=456"
"--test-epsilon=123"))
(test '("the-command"
"--method=minkowsky-space-time-chess-opening"
"--subintervals=456" "--test-epsilon=123"))
;; end of file
--
Marco Maggi
"Now feel the funk blast!"
Rage Against the Machine - "Calm like a bomb"