including modules - ordering question

A

Aryk Grosz

Hi,

I have a module where I include modules as usual:

module A
module B
end
module C
include B
include D
end
module D
end

end

When I require this file, I'll get an error here because module D is
being included before it gets loaded. I would need to put it above
module C to get it to work. How can I load the file, and then do all the
includes so that it can actually find the module.
 
A

Alex Gutteridge

Hi,

I have a module where I include modules as usual:

module A
module B
end
module C
include B
include D
end
module D
end

end

When I require this file, I'll get an error here because module D is
being included before it gets loaded. I would need to put it above
module C to get it to work. How can I load the file, and then do
all the
includes so that it can actually find the module.

Perhaps I'm missing something, but haven't you answered your own
question...
I would need to put it above module C to get it to work.

So the structure of the file should look like this:
module A
module B
end
module D
end
module C
include B
include D
end
end

Perhaps there is something more complicated going on in your example
that I am not understanding?

Alex Gutteridge

Bioinformatics Center
Kyoto University
 
F

F. Senault

Le 27 juin à 06:36, Aryk Grosz a écrit :
When I require this file, I'll get an error here because module D is
being included before it gets loaded. I would need to put it above
module C to get it to work. How can I load the file, and then do all the
includes so that it can actually find the module.

Not sure how (if) it would work, but can't you just define an empty
Module D with "module D ; end" and then reopen it after :

module A
module B
# code
end
module D ; end
module C
include B
include D
# code
end
module D
# code
end
end

Fred
--
Very _basic_ coffeemakers.
10 BREW $CF | 40 DRINK $CF
20 IF $CF<=0 THEN GOTO 10 | 50 GOTO 20
30 POUR $CF (Graham Reed in the Scary Devil Monastery)
 
A

Aryk Grosz

Well, basically Im looking for a solution where order doesn't matter.
Hmm, I wonder if that trick with the module would work. It's kind of
hacky. Wonder if there is a better way or maybe you just have to be
aware of order all the time.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,053
Latest member
BrodieSola

Latest Threads

Top