unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* url/url.el - Duplicate requires
@ 2005-10-14  9:01 Cheng Gao
  2005-10-14 10:17 ` David Kastrup
  2005-10-14 20:54 ` Stefan Monnier
  0 siblings, 2 replies; 3+ messages in thread
From: Cheng Gao @ 2005-10-14  9:01 UTC (permalink / raw)


Line 44-46:
,----
| (eval-when-compile
|   (require 'mm-decode)
|   (require 'mm-view))
`----
But line 237-241:
,----
| (defun url-mm-url (url)
|   "Retrieve URL and pass to the appropriate viewing application."
|   (require 'mm-decode)
|   (require 'mm-view)
|   (url-retrieve url 'url-mm-callback nil))
`----
mm-decode and mm-view are required again.

Should the requires in function url-mm-url be removed?

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

* Re: url/url.el - Duplicate requires
  2005-10-14  9:01 url/url.el - Duplicate requires Cheng Gao
@ 2005-10-14 10:17 ` David Kastrup
  2005-10-14 20:54 ` Stefan Monnier
  1 sibling, 0 replies; 3+ messages in thread
From: David Kastrup @ 2005-10-14 10:17 UTC (permalink / raw)
  Cc: emacs-devel

Cheng Gao <chenggao@gmail.com> writes:

> Line 44-46:
> ,----
> | (eval-when-compile
> |   (require 'mm-decode)
> |   (require 'mm-view))
> `----
> But line 237-241:
> ,----
> | (defun url-mm-url (url)
> |   "Retrieve URL and pass to the appropriate viewing application."
> |   (require 'mm-decode)
> |   (require 'mm-view)
> |   (url-retrieve url 'url-mm-callback nil))
> `----
> mm-decode and mm-view are required again.
>
> Should the requires in function url-mm-url be removed?

require at run-time is a bad idea, and constructs like above with
eval-when-compile tend to create byte compiler warnings.  I think the
correct way to deal with this would be something like

(autoload 'url-retrieve 'mm-decode)
(defun url-mm-url (url)
  (url-retrieve url ...

That way, the byte compiler is satisfied, and no runtime performance
hit is scored by unneeded requires.

-- 
David Kastrup, Kriemhildstr. 15, 44793 Bochum

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

* Re: url/url.el - Duplicate requires
  2005-10-14  9:01 url/url.el - Duplicate requires Cheng Gao
  2005-10-14 10:17 ` David Kastrup
@ 2005-10-14 20:54 ` Stefan Monnier
  1 sibling, 0 replies; 3+ messages in thread
From: Stefan Monnier @ 2005-10-14 20:54 UTC (permalink / raw)
  Cc: emacs-devel

> Line 44-46:
> ,----
> | (eval-when-compile
> |   (require 'mm-decode)
> |   (require 'mm-view))
> `----
> But line 237-241:
> ,----
> | (defun url-mm-url (url)
> |   "Retrieve URL and pass to the appropriate viewing application."
> |   (require 'mm-decode)
> |   (require 'mm-view)
> |   (url-retrieve url 'url-mm-callback nil))
> `----
> mm-decode and mm-view are required again.

> Should the requires in function url-mm-url be removed?

The requires aren't done at the same time so they are "unrelated".
The first ones above are just there to quieten the byte-compiler and to
define some macros (e.g. mm-handle-undisplayer) used during
byte-compilation.  The second are because url-mm-callback actually uses
functions from those libs at run time.

So all in all, the current code looks OK.  I'd be tempted to move the last
two require from url-mm-url (where the functions they define aren't
actually used) to url-mm-callback (where they are used), or to define
autoloads, as suggested by David.  But I suspect there's a good reason why
they're in url-mm-url, probably having to do with the fact that
url-mm-callback is usually called from a process sentinel or process filter,
and loading mm-decode or mm-view at that point may lead to problems (maybe
some global vars are let-bound at that point and interact poorly with the
loading of mm-decode or mm-view).  None of the historical data (such as the
ChangeLog or the CVS files in the older URL subversions package) allows me
to confirm since this code predates the URL package (it probably goes back
to the time when URL was part of W3).

I.e. if I were you, I'd add a comment explaining something like the above as
a justification for why we didn't change the code.


        Stefan

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

end of thread, other threads:[~2005-10-14 20:54 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-10-14  9:01 url/url.el - Duplicate requires Cheng Gao
2005-10-14 10:17 ` David Kastrup
2005-10-14 20:54 ` Stefan Monnier

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).