all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Drew Adams <drew.adams@oracle.com>
To: Thorsten Jolitz <tjolitz@gmail.com>, help-gnu-emacs@gnu.org
Subject: RE: Circular dependencies between libraries - what to do?
Date: Sat, 20 Sep 2014 18:52:59 -0700 (PDT)	[thread overview]
Message-ID: <88832444-184c-4cbd-8147-1114b5e78dcb@default> (raw)
In-Reply-To: <87d2aqgf92.fsf@gmail.com>

> I have libraries that depend on each other, and I'm not sure
>  (1) how to use require without introducing circular dependencies?
>  (2) how to declare their dependencies as MELPA packages?
> 
> 1. When I put in
> ,----
> | A
> | (require 'B)
> `----
> and in
> ,----
> | B
> | (require 'A)
> `----
> 
> I'm probably asking for trouble, but B actually does not work
> without A, and A calls B functions, so they do require each other.

If these are your own libraries, so that you can modify their code,
then break them into pieces, and then reorder and recombine pieces.

Here is the guiding principle:

  It is not *all* of A that requires *all* of B, and
  it is not *all* of B that requires *all* of A.

So look at the code carefully and find which pieces have hard
(i.e., logical) dependencies on which other pieces.  Keep pieces
that must be together together; separate (at least logically and
temporarily) things that can be separated.

When you have something that makes sense, and thus works, then
you can try combining pieces to end up with fewer and larger
ones.  You might find that you end up with more than two files.
Or you might find that you end up with only one file, but
better structured (e.g. reordered).

You will have, at least during the exercise, made any real
dependencies explicit.  You will understand your code better,
and you will make it easier to modify it in the future.

Yes, this can take some time.  Two aids are:
1. The byte-compiler, as others have mentioned.
2. Commenting-out sections of code temporarily, using, e.g.,
   `comment-region' (with `C-u' it uncomments).



  parent reply	other threads:[~2014-09-21  1:52 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-20 21:21 Circular dependencies between libraries - what to do? Thorsten Jolitz
2014-09-20 22:49 ` Thorsten Jolitz
2014-09-20 22:52 ` Stefan Monnier
2014-09-21  0:04   ` Thorsten Jolitz
     [not found] ` <mailman.9278.1411257340.1147.help-gnu-emacs@gnu.org>
2014-09-21  1:42   ` Emanuel Berg
2014-09-21  1:52 ` Drew Adams [this message]
2014-09-21 10:37   ` Thorsten Jolitz
     [not found] <mailman.9267.1411248102.1147.help-gnu-emacs@gnu.org>
2014-09-20 21:40 ` Emanuel Berg
2014-09-20 22:03   ` Thorsten Jolitz
     [not found]   ` <mailman.9277.1411257339.1147.help-gnu-emacs@gnu.org>
2014-09-30 14:25     ` Christoph Wedler
2014-09-30 14:38       ` Thorsten Jolitz
2014-09-30 19:05         ` Stefan Monnier
2014-10-06 16:30           ` Aurélien Aptel
     [not found]       ` <mailman.10067.1412088616.1147.help-gnu-emacs@gnu.org>
2014-09-30 21:28         ` Emanuel Berg

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=88832444-184c-4cbd-8147-1114b5e78dcb@default \
    --to=drew.adams@oracle.com \
    --cc=help-gnu-emacs@gnu.org \
    --cc=tjolitz@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.