all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* How to avoid introducing global symbols by setq in function?
@ 2016-11-18  1:10 zhanghj
  2016-11-18  8:33 ` Marcin Borkowski
  0 siblings, 1 reply; 3+ messages in thread
From: zhanghj @ 2016-11-18  1:10 UTC (permalink / raw
  To: help-gnu-emacs

As in the following code:

(let ((var1 100))  ;; default value
  (when some_condition
    ;; new value
    (setq varl 200))
  (message "value: %d" varl))

Should use "var1", but write "varl" by typo.
If some_condition is non-nil, there will be no error and no warnning.

How to check these mistakes?



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: How to avoid introducing global symbols by setq in function?
  2016-11-18  1:10 How to avoid introducing global symbols by setq in function? zhanghj
@ 2016-11-18  8:33 ` Marcin Borkowski
  2016-11-21  8:30   ` zhanghj
  0 siblings, 1 reply; 3+ messages in thread
From: Marcin Borkowski @ 2016-11-18  8:33 UTC (permalink / raw
  To: zhanghj; +Cc: help-gnu-emacs


On 2016-11-18, at 02:10, zhanghj <netjunegg@gmail.com> wrote:

> As in the following code:
>
> (let ((var1 100))  ;; default value
>   (when some_condition
>     ;; new value
>     (setq varl 200))
>   (message "value: %d" varl))
>
> Should use "var1", but write "varl" by typo.
> If some_condition is non-nil, there will be no error and no warnning.
>
> How to check these mistakes?

Have you tried to byte-compile that code?

Best,

-- 
Marcin Borkowski



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: How to avoid introducing global symbols by setq in function?
  2016-11-18  8:33 ` Marcin Borkowski
@ 2016-11-21  8:30   ` zhanghj
  0 siblings, 0 replies; 3+ messages in thread
From: zhanghj @ 2016-11-21  8:30 UTC (permalink / raw
  To: Marcin Borkowski; +Cc: help-gnu-emacs

I just tried. The warnning message told me what I want. Thank you.



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-11-21  8:30 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-11-18  1:10 How to avoid introducing global symbols by setq in function? zhanghj
2016-11-18  8:33 ` Marcin Borkowski
2016-11-21  8:30   ` zhanghj

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.