[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

including modules - ordering question

Aryk Grosz

6/27/2007 4:37:00 AM

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.

--
Posted via http://www.ruby-....

3 Answers

Alex Gutteridge

6/27/2007 5:38:00 AM

0

On 27 Jun 2007, at 13:36, Aryk Grosz wrote:

> 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. Senault

6/27/2007 9:16:00 AM

0

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)

Aryk Grosz

6/27/2007 5:22:00 PM

0

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.

--
Posted via http://www.ruby-....