help-gnu-emacs
[Top][All Lists]
Advanced

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

RE: Are nested defun's byte-compiled?


From: Drew Adams
Subject: RE: Are nested defun's byte-compiled?
Date: Tue, 24 May 2005 10:46:03 -0700

Trying this again, as I received no response. Thanks, Drew.

    Sent: Sunday, May 15, 2005 3:48 PM

    Is the code defining a nested defun byte-compiled when its
    enclosing defun
    is compiled? Example source file foo.el:

    (defcustom define-bar-flag t "Define `bar' if non-nil.")
    (defun foo ()
      "Do foo stuff. Define `bar' if `define-bar-flag' is non-nil."
      (when define-bar-flag (defun bar () (bar-stuff)))
      (rest-of-foo-stuff))

    Suppose foo.el is byte-compiled, and then foo.elc is loaded.

    Is `define-bar-flag' eval'd when compiling foo? I assume not. I
    assume that
    `bar' is not defined if `define-bar-flag' was set to nil before
    foo.elc is
    loaded. I assume that `bar' is not defined until `(foo)' is
    executed, and
    then only if `define-bar-flag' is non-nil.

    When foo.el was byte-compiled, is bar's potential definition (the defun
    itself) also byte-compiled or not? That is, if `(foo)' is executed after
    loading foo.elc, which version of `bar' is defined,
    byte-compiled or not?

    If the answer is that the non-compiled version of `bar' is
    defined, how can
    the code be changed to make the compiled version be defined
    instead? Is this
    a good way to do that?

    (defun foo ()
      (when define-bar-flag (byte-compile (defun bar () (bar-stuff))))
      (rest-of-foo-stuff))





reply via email to

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