[Top][All Lists]

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

RE: Qs on free variable occurrences

From: Drew Adams
Subject: RE: Qs on free variable occurrences
Date: Sat, 6 May 2006 07:57:43 -0700

Resending, as I got no reply. Suppose this variable were not predefined in
C. Would the Lisp coding style used be appropriate in that case, or should
the variable be declared via `defvar'?

        Consider variable `minibuffer-history-position', in library

        1. It is bound (`let') in function `repeat-complex-command'.

        2. It is assigned a value at the top level of the file.

        3. It is both used (evaluated) and assigned a value in
           functions `previous-matching-history-element' and

        4. Byte-compiling the file gives no warning of the variable
           being used as a free variable (in #3 and #4).

        This is not a criticism, but a couple of questions.

        a. Why #4? Is it because the byte-compiler cannot detect these
           as free occurrences of the variable or is it intentional
           (TRT)? If the latter, what's the rationale?

        b. Is this coding style considered good or bad? In particular,
           should `minibuffer-history-position' be declared a global
           variable by giving it a defvar?

        Just trying to learn. Supporting reasons would help me understand.

    `C-h v' says that this variable is defined in C source code. That
    would perhaps explain #4. I still wonder about the coding style.
    Consider my questions in a context where the variable was not
    predefined in C. Thx.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]