[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Are nested defun's byte-compiled?
From: |
Thierry Emery |
Subject: |
Re: Are nested defun's byte-compiled? |
Date: |
Wed, 25 May 2005 00:15:41 +0200 |
User-agent: |
T-gnus/6.17.3 (based on No Gnus v0.3) SEMI/1.14.6 (Maruoka)FLIM/1.14.7 (Sanjō) APEL/10.6 Emacs/22.0.50 (gnu/linux) MULE/5.0 (SAKAKI) |
"Drew Adams" <drew.adams@oracle.com> writes:
> 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
[random speculations snipped]
If you open foo.elc with Emacs, you can see that the compiled definition
for `foo' contains a compiled definition for `bar'.
If you still have a doubt, you can:
M-x load-file
foo.elc
ESC ESC :
(foo)
;; this defines `bar' and signals an error because `rest-of-foo-stuff'
;; is not defined...
M-x debug-on-entry
bar
ESC ESC :
(bar)
d
;; and you see:
Debugger entered--beginning evaluation of function call form:
* (byte-code "À �" [bar-stuff] 1)
* bar()
eval((bar))
eval-expression((bar) nil)
call-interactively(eval-expression)
HTH,
Thierry
--
thierry |point| emery |chez| free |point| fr