I want to get the effect of a static variable by using
defun inside of
let with lexical binding to create a closure. However, when byte-compiling the file, I get a warning. Am I doing something wrong, or if not, is there a way to suppress this warning?
I've created an MCVE:
;; -*- lexical-binding: t -*- (let ((count 0)) (defun increase-count () (interactive) (setq count (1+ count)) (message "Count is: %d" count)) ;; The warning happens here. (increase-count))
The code works as expected: the function
increase-count prints out "Count is: n" where n increases each time it is called. However, when byte-compiling this file, I get the following warning:
In end of data: mcve.el:11:1:Warning: the function ‘increase-count’ is not known to be defined.
It seems to me that
increase-count should always be defined before it is called at the end of the let-block. Is this not the case?