I have this function:
(defun uikit-autolayout (stackview)
"Ask STACKVIEW to auto layout."
(let* ((orientation-index (pcase (uikit--orientation-of stackview)
('left 0) ; rotate clockwise 0 degree
('bottom 1) ; rotate 90 degree
('right 2) ; 180 degree
('top 3))) ; 270 degree
(last-left (byte-compile (lambda (SELF) (ignore SELF) (uikit-left-of stackview))))
(space-func (pcase (uikit--autolayout-of stackview)
('stacking (byte-compile (lambda () (uikit--stacking-space-of stackview))))
('equal-spacing #'uikit-equal-spacing-space-of)))
(top-func (pcase (uikit--v-align-of stackview)
('top (lambda (SELF) (uikit-top-of (uikit--parent-stackview-of SELF))))
('center (lambda (SELF)
(+ (uikit-top-of (uikit--parent-stackview-of SELF))
(/ (- (uikit--max-subview-height (uikit--parent-stackview-of SELF))
(uikit-content-height-of SELF)) 2))))
('bottom (lambda (SELF)
(- (uikit-bottom-of (uikit--parent-stackview-of SELF))
(uikit-content-width-of SELF)))))))
(let ((uikit-left-of (nth orientation-index '(uikit-left-of uikit-bottom-of uikit-right-of uikit-top-of)))
(uikit-bottom-of (nth orientation-index '(uikit-bottom-of uikit-right-of uikit-top-of uikit-left-of)))
(uikit-right-of (nth orientation-index '(uikit-right-of uikit-top-of uikit-left-of uikit-bottom-of)))
(uikit-top-of (nth orientation-index '(uikit-top-of uikit-left-of uikit-bottom-of uikit-right-of))))
;; ??? unused lexical variable xxx
(ignore last-left space-func top-func uikit-left-of uikit-bottom-of uikit-right-of uikit-top-of)
;; during the drawing process `uikit-<constrain>-of' will be
;; bind to another function that calculates the constrain into
;; actual number and saves to cache
(dolist (subview (uikit--subview-list-of stackview))
;; autolayout yourself if you are a stackview
(when (cl-typep subview 'uikit-stackview)
(uikit-autolayout subview))
;; set your parent
(setf (uikit--parent-stackview-of subview) stackview)
;; set your left to the right of the previous view
(uikit-left-of subview last-left)
(setq last-left (byte-compile (lambda (SELF) (ignore SELF)
(+ (uikit-right-of subview)
(funcall space-func)))))
;; top & bottom
(uikit-top-of subview top-func)))))
When I run it, following warnings pop up:
Warning: Unused lexical variable ‘orientation-index’
Warning: Unused lexical variable ‘orientation-index’
Warning: Unused lexical variable ‘last-left’
Warning: Unused lexical variable ‘stackview’
Warning: Unused lexical variable ‘orientation-index’
Warning: Unused lexical variable ‘last-left’
Warning: Unused lexical variable ‘top-func’
Warning: Unused lexical variable ‘uikit-left-of’
Warning: Unused lexical variable ‘uikit-bottom-of’
Warning: Unused lexical variable ‘uikit-right-of’
Warning: Unused lexical variable ‘uikit-top-of’
Warning: Unused lexical variable ‘--dolist-tail--’
Warning: Unused lexical variable ‘stackview’
Warning: Unused lexical variable ‘orientation-index’
Warning: Unused lexical variable ‘last-left’
Warning: Unused lexical variable ‘top-func’
Warning: Unused lexical variable ‘uikit-left-of’
Warning: Unused lexical variable ‘uikit-bottom-of’
Warning: Unused lexical variable ‘uikit-right-of’
Warning: Unused lexical variable ‘uikit-top-of’
All these variables are those I declared in let
binding,
and I used them (except uikit-left/top/bottom/right-of
).
I tried to "use" then with a ignore
call, but that doesn't help.
Why am I getting these warnings and how can I fix the problem?
P.S. When I byte compile the file, everything is fine, no warnnings.
UPDATE:
As Stefan and Phill says, when I remove the byte-compile
function it doesn't show warnings anymore. And yes, I don't really need to use byte-compile
the first place. Thanks! It's interesting that byte-compile compiles closures back into lambda, I never thought it will do that sort of thing.