all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Keeping run-time code from running at compile-time
       [not found] <4951.1128644991@olgas.newt.com>
@ 2005-10-07  5:06 ` Bill Wohler
  2005-10-07  5:09   ` Bill Wohler
  2005-10-07  5:09 ` Bill Wohler
       [not found] ` <mailman.10195.1128661802.20277.help-gnu-emacs@gnu.org>
  2 siblings, 1 reply; 5+ messages in thread
From: Bill Wohler @ 2005-10-07  5:06 UTC (permalink / raw)


[-- Attachment #1: Type: text/plain, Size: 721 bytes --]

I'm having some compiling trouble. File B which requires file A fails to
compile because file A contains code that should not be run at
compile-time, just run-time.

I've distilled the essence into a tiny example. Save the attachments
with "K a" and then run the script doit. Right now, I'm getting the
output:

    [wohler@olgas:807]$ sh doit
    While compiling toplevel forms in file /tmp/b.el:
      !! error (("Shouldn't hit this when compiling"))
    Done
    Loading b (source)...
    Shouldn't hit this when compiling

I'd like to get the output:

    [wohler@olgas:807]$ sh doit
    Wrote /tmp/b.elc
    Done
    Loading b (source)...
    Shouldn't hit this when compiling

Thanks for any help you can provide.


[-- Attachment #2: doit --]
[-- Type: application/x-shellscript, Size: 299 bytes --]

[-- Attachment #3: a.el --]
[-- Type: text/plain, Size: 80 bytes --]

(defun foo ()
  (error "Shouldn't hit this when compiling"))
(foo)
(provide 'a)

[-- Attachment #4: b.el --]
[-- Type: text/plain, Size: 62 bytes --]

(require 'a)
(defun doit ()
  (message "%s" "Hello, world!"))

[-- Attachment #5: Type: text/plain, Size: 199 bytes --]


-- 
Bill Wohler <wohler@newt.com>  http://www.newt.com/wohler/  GnuPG ID:610BD9AD
Maintainer of comp.mail.mh FAQ and MH-E. Vote Libertarian!
If you're passed on the right, you're in the wrong lane.

[-- Attachment #6: Type: text/plain, Size: 149 bytes --]

_______________________________________________
Bug-gnu-emacs mailing list
Bug-gnu-emacs@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-gnu-emacs

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

* Re: Keeping run-time code from running at compile-time
  2005-10-07  5:06 ` Keeping run-time code from running at compile-time Bill Wohler
@ 2005-10-07  5:09   ` Bill Wohler
  0 siblings, 0 replies; 5+ messages in thread
From: Bill Wohler @ 2005-10-07  5:09 UTC (permalink / raw)


Apologies. That was meant for help-gnu-emacs@gnu.org.

-- 
Bill Wohler <wohler@newt.com>  http://www.newt.com/wohler/  GnuPG ID:610BD9AD
Maintainer of comp.mail.mh FAQ and MH-E. Vote Libertarian!
If you're passed on the right, you're in the wrong lane.

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

* Keeping run-time code from running at compile-time
       [not found] <4951.1128644991@olgas.newt.com>
  2005-10-07  5:06 ` Keeping run-time code from running at compile-time Bill Wohler
@ 2005-10-07  5:09 ` Bill Wohler
       [not found] ` <mailman.10195.1128661802.20277.help-gnu-emacs@gnu.org>
  2 siblings, 0 replies; 5+ messages in thread
From: Bill Wohler @ 2005-10-07  5:09 UTC (permalink / raw)


[-- Attachment #1: Type: text/plain, Size: 721 bytes --]

I'm having some compiling trouble. File B which requires file A fails to
compile because file A contains code that should not be run at
compile-time, just run-time.

I've distilled the essence into a tiny example. Save the attachments
with "K a" and then run the script doit. Right now, I'm getting the
output:

    [wohler@olgas:807]$ sh doit
    While compiling toplevel forms in file /tmp/b.el:
      !! error (("Shouldn't hit this when compiling"))
    Done
    Loading b (source)...
    Shouldn't hit this when compiling

I'd like to get the output:

    [wohler@olgas:807]$ sh doit
    Wrote /tmp/b.elc
    Done
    Loading b (source)...
    Shouldn't hit this when compiling

Thanks for any help you can provide.


[-- Attachment #2: doit --]
[-- Type: application/x-shellscript, Size: 299 bytes --]

[-- Attachment #3: a.el --]
[-- Type: text/plain, Size: 80 bytes --]

(defun foo ()
  (error "Shouldn't hit this when compiling"))
(foo)
(provide 'a)

[-- Attachment #4: b.el --]
[-- Type: text/plain, Size: 62 bytes --]

(require 'a)
(defun doit ()
  (message "%s" "Hello, world!"))

[-- Attachment #5: Type: text/plain, Size: 199 bytes --]


-- 
Bill Wohler <wohler@newt.com>  http://www.newt.com/wohler/  GnuPG ID:610BD9AD
Maintainer of comp.mail.mh FAQ and MH-E. Vote Libertarian!
If you're passed on the right, you're in the wrong lane.

[-- Attachment #6: Type: text/plain, Size: 152 bytes --]

_______________________________________________
Help-gnu-emacs mailing list
Help-gnu-emacs@gnu.org
http://lists.gnu.org/mailman/listinfo/help-gnu-emacs

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

* Re: Keeping run-time code from running at compile-time
       [not found] ` <mailman.10195.1128661802.20277.help-gnu-emacs@gnu.org>
@ 2005-10-07 16:45   ` rgb
  2005-10-11  3:48   ` Stefan Monnier
  1 sibling, 0 replies; 5+ messages in thread
From: rgb @ 2005-10-07 16:45 UTC (permalink / raw)


> (defun foo ()
>   (error "Shouldn't hit this when compiling"))
> (foo)

You are explicitly invoking foo here.
The only difference between (defun ...) and (foo ...) in
any file that you require or load is in your mind.
They are just functions to be executed.  Lisp doesn't
care if they are named def<something> or not.

> (provide 'a)
>
> (require 'a)
> (defun doit ()
>   (message "%s" "Hello, world!"))
>

To achieve what you seem to want you need:

---x---
(defun foo ()
  (error "Shouldn't hit this when compiling"))
(provide 'x)
---a---
(require 'x)
(foo)
(provide 'a)
---b---
> (require 'x)
> (defun doit ()
>   (message "%s" "Hello, world!"))

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

* Re: Keeping run-time code from running at compile-time
       [not found] ` <mailman.10195.1128661802.20277.help-gnu-emacs@gnu.org>
  2005-10-07 16:45   ` rgb
@ 2005-10-11  3:48   ` Stefan Monnier
  1 sibling, 0 replies; 5+ messages in thread
From: Stefan Monnier @ 2005-10-11  3:48 UTC (permalink / raw)


> I'm having some compiling trouble. File B which requires file A fails to
> compile because file A contains code that should not be run at
> compile-time, just run-time.

Basically you're saying that the compiler should either not load file A when
compiling file B, or load it be "weakly".

Such issues is one of the reasons why toplevel expressions in .el files
should do as little as possible.  So most likely the problem is that your
toplevel expressions in file A should be moved to a function that is called
explicitly from elsewhere (e.g. from a major mode function).


        Stefan

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

end of thread, other threads:[~2005-10-11  3:48 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <4951.1128644991@olgas.newt.com>
2005-10-07  5:06 ` Keeping run-time code from running at compile-time Bill Wohler
2005-10-07  5:09   ` Bill Wohler
2005-10-07  5:09 ` Bill Wohler
     [not found] ` <mailman.10195.1128661802.20277.help-gnu-emacs@gnu.org>
2005-10-07 16:45   ` rgb
2005-10-11  3:48   ` Stefan Monnier

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.