Does anyone know why the following script (it is just the bare
skeleton of another script doing something actually useful) gives the
message "Warning: invalid variable reference" (twice!) on Scsh 0.6.4?
(Also see the transcript below)
The warning is triggered by the (ERROR MSG) form in MYUSAGE; if I
comment that out the warning is silenced. But I don't see why the call
to ERROR should be ``invalid'' here. Evaluating the definition of
MYUSAGE directly in the REPL works just fine, both in the 'user' and
in the 'frobnicate' package . What am I missing?
,----
| #!/usr/local/bin/scsh \
| -dm -o frobnicate -e start -s
| !#
|
| (define-structure frobnicate
|
| (export start)
|
| (open srfi-28 ;basic format strings
| scsh
| scheme)
|
| (begin
|
| (define (start argument-list)
| (let ((num-args (max (- (length argument-list) 1) 0)))
| (cond
| ((not (= num-args 2)) (myusage))
| (else
| (let* ((first (string->symbol (cadr argument-list)))
| (second (caddr argument-list)))
| (case first
| ((frob twiddle tweak) (frobnicate first second))
| (else (myusage))))))))
|
| (define (myusage)
| (let ((msg "Myusage: frobnicate frob|twiddle|tweak SECONDARG"))
| ; (begin (display msg) (newline) (exit 1))
| (error msg)
^^^^^^^^^^^
| ))
|
| (define (frobnicate first second)
| (display (format "~a~aing ~a...~%"
| first
| (case first
| ((frob) "b") ((twiddle) (ascii->char 8)) (else ""))
| second)))
|
| ) ;closes (begin
| (optimize auto-integrate)) ;closes (define-structure frobnicate
`----
Sample session transcript:
,----
| -- Welcome to scsh 0.6.4 (Olin Shivers)
| Type ,? for help.
| > ,config ,load frob.scm
| frob.scm
| > ,open frobnicate
| Load structure frobnicate (y/n)? y
| [srfi-23]
| [srfi-6]
| [srfi-28 /usr/local/lib/scsh/srfi/srfi-28.scm]
| [frobnicate
| Analyzing... no in-line procedures
|
| Warning: invalid variable reference
| myusage
| #{Package 227 frobnicate}
|
| Warning: invalid variable reference
| myusage
| #{Package 227 frobnicate}
| ]
| >
`----
--
Stefan Jankowski
s/spambucket//
s/dave\.null/janky/
|