(define-method/cgen 'REFERENCE
(lambda (interns expression)
+ (if (variable/must-ignore? (reference/variable expression))
+ (warn "Variable declared IGNORE, but was used: "
+ (variable/name (reference/variable expression))))
(cgen/variable interns (reference/variable expression))))
(define-method/cgen 'SEQUENCE
(define-flag SIDE-EFFECTED variable/side-effected variable/side-effect!)
(define-flag REFERENCED variable/referenced variable/reference!)
(define-flag INTEGRATED variable/integrated variable/integrated!)
-(define-flag CAN-IGNORE variable/can-ignore? variable/can-ignore!)
+(define-flag MAY-IGNORE variable/may-ignore? variable/may-ignore!)
+(define-flag MUST-IGNORE variable/must-ignore? variable/must-ignore!)
(define open-block/value-marker
;; This must be an interned object because we will fasdump it and
\f
;;;; Flag Declarations
+;; IGNORABLE suppresses warnings about the variable not being used.
+;; This is useful in macros that bind variables that the body may
+;; not actually use. Mentioning the variable in a sequence will
+;; have the effect of marking it ignorable.
+(define-declaration 'IGNORABLE
+ (lambda (block names)
+ (for-each (lambda (variable)
+ (if variable
+ (variable/may-ignore! variable)))
+ (block/lookup-names block names #f))
+ '()))
+
+;; IGNORE causes warnings if an ignored variable actually ends
+;; up being used.
(define-declaration 'IGNORE
(lambda (block names)
(for-each (lambda (variable)
(if variable
- (variable/can-ignore! variable)))
+ (variable/must-ignore! variable)))
(block/lookup-names block names #f))
'()))
\f
(define (variable/unreferenced? variable)
(and (not (variable/integrated variable))
(not (variable/referenced variable))
- (not (variable/can-ignore? variable))))
+ (not (variable/may-ignore? variable))
+ (not (variable/must-ignore? variable))))
(define-method/integrate 'PROCEDURE
(lambda (operations environment procedure)
(cons (cond ((reference? action)
;; This clause lets you ignore a variable by
;; mentioning it in a sequence.
- (variable/can-ignore! (reference/variable action))
+ (variable/may-ignore! (reference/variable action))
action)
((eq? action open-block/value-marker)
action)