all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Qs on free variable occurrences
@ 2006-05-01 21:25 Drew Adams
  2006-05-01 21:29 ` Drew Adams
  0 siblings, 1 reply; 5+ messages in thread
From: Drew Adams @ 2006-05-01 21:25 UTC (permalink / raw)


Consider variable `minibuffer-history-position', in library simple.el.

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 `next-history-element'.

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. Thx.

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

* RE: Qs on free variable occurrences
  2006-05-01 21:25 Qs on free variable occurrences Drew Adams
@ 2006-05-01 21:29 ` Drew Adams
  2006-05-06 14:57   ` Drew Adams
  0 siblings, 1 reply; 5+ messages in thread
From: Drew Adams @ 2006-05-01 21:29 UTC (permalink / raw)


    Consider variable `minibuffer-history-position', in library simple.el.

    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
    `next-history-element'.

    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.

I should have tried `C-h v' first. It 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.

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

* RE: Qs on free variable occurrences
  2006-05-01 21:29 ` Drew Adams
@ 2006-05-06 14:57   ` Drew Adams
  2006-05-07  5:00     ` Richard Stallman
  0 siblings, 1 reply; 5+ messages in thread
From: Drew Adams @ 2006-05-06 14:57 UTC (permalink / raw)


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
        simple.el.

        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
           `next-history-element'.

        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.

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

* Re: Qs on free variable occurrences
  2006-05-06 14:57   ` Drew Adams
@ 2006-05-07  5:00     ` Richard Stallman
  2006-05-07 14:54       ` Drew Adams
  0 siblings, 1 reply; 5+ messages in thread
From: Richard Stallman @ 2006-05-07  5:00 UTC (permalink / raw)
  Cc: emacs-devel

	    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?

It is because the variable has a definition elsewhere.
(In the C code.)

I will add a comment to say so.

	    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?

If it weren't used in the C code, that's what we'd do.

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

* RE: Qs on free variable occurrences
  2006-05-07  5:00     ` Richard Stallman
@ 2006-05-07 14:54       ` Drew Adams
  0 siblings, 0 replies; 5+ messages in thread
From: Drew Adams @ 2006-05-07 14:54 UTC (permalink / raw)


    	    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?

    If it weren't used in the C code, that's what we'd do.

Thx. That's what I thought, but I wanted to make sure I wasn't missing
something.

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

end of thread, other threads:[~2006-05-07 14:54 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-05-01 21:25 Qs on free variable occurrences Drew Adams
2006-05-01 21:29 ` Drew Adams
2006-05-06 14:57   ` Drew Adams
2006-05-07  5:00     ` Richard Stallman
2006-05-07 14:54       ` Drew Adams

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.