Google Groups Home
Help | Sign in
Message from discussion circular module dependency
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
Richard Maine  
View profile
 More options May 8, 3:12 pm
Newsgroups: comp.lang.fortran
From: nos...@see.signature (Richard Maine)
Date: Thu, 8 May 2008 12:12:44 -0700
Local: Thurs, May 8 2008 3:12 pm
Subject: Re: circular module dependency

Gene Wagenbreth <genewxxx@isi-OS4> wrote:
> module A uses module B because it calls a routine in module B

> module B uses module A because it calls a routine in module A

> neither compiles because each needs the other mod file.

> So in A I comment out the use of B and the calls to B. I compile
> A. Then I compile B. Then I uncomment the use of B and the calls to
> B in A. Then I compile A. From then on I can compile each as long
> as I dont change the calling sequences and I dont make clean.

> This is silly, ugly, etc, but it works.

> What am I missing ?

Only the fact that the code is nonstandard and that such hacks are
highly compiler dependent. The "it works" is a bit of an overstatement,
which needs to be qualified with particular compiler details, possibly
including the version number. Which is to say that this is asking for
future trouble.

I'm trying to recall the ways for working around this problem. Of
course, one "obvious" way is to reorganize things so that it doesn't
come up, but I understand that isn't always practical.

Another way is to throw an external procedure into the mix. That's a bit
of a hack, but at least it can be standard conforming. There isn't a
limitation on invoking module procedures circularly like that - just on
having circularity in the USE statements. So having an external
procedure breaks the USE circularity.

--
Richard Maine                    | Good judgement comes from experience;
email: last name at domain . net | experience comes from bad judgement.
domain: summertriangle           |  -- Mark Twain


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2008 Google