[Date Prev][Date Next][Thread Prev][][Date Index][Thread Index]

lexical-binding question


Could anyone explain why this form works with no error?
(Note that I'm talking about the latest emacs-w3m code.)

(let ((w3m-input-coding-system 'binary))
    (w3m-rendering-half-dump 'big5)))

The point is that this form substitutes the symbols `charset'
that are defined in the `w3m-halfdump-command-arguments' constant
with `big5' with no error occurring.

The following forms are utmost simplified model of the functions
that the above form uses:

--8<---------------cut here---------------start------------->8---
;; -*- lexical-binding: t -*-
(defun fn1 () ;; simplified `w3m-w3m-expand-arguments'
  (eval '`,charset))

(defun fn2 (charset) ;; simplified `w3m-rendering-half-dump'
  (ignore charset) ;; Silence the byte compiler.

(defun fn3 (&optional charset) ;; simplified `w3m-rendering-buffer'
  (fn2 charset))
--8<---------------cut here---------------end--------------->8---

But, as you may see, (fn3 'big5) causes an error.  The difference
is that the symbol `charset' is boundp and can be examined the
value by `C-h v' when edebugging `w3m-w3m-expand-arguments' only
with the emacs-w3m code.