Questions tagged «lexical-binding»

3
用词法绑定的let内部的Defun给出字节编译警告“该函数未知”
我想通过使用带有词法绑定的defun内部let来创建闭包来获得静态变量的效果。但是,当字节编译文件时,出现警告。我是在做错什么,否则,是否有办法抑制此警告? 我创建了一个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)) 代码按预期工作:函数increase-count打印出“ Count is:n”,其中n在每次调用时都会增加。但是,当字节编译此文件时,出现以下警告: In end of data: mcve.el:11:1:Warning: the function ‘increase-count’ is not known to be defined. 在我看来,increase-count应该始终在let块末尾调用它之前定义它。不是这样吗?
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.