"cyclic include" error inside anonymous module

(Brian Candler) #1

> Perhaps it would be clearest if you gave an example of why it is needed? I
> have given you an example of where it breaks things :slight_smile:

Use -w with your script

I guess I'm not communicating very well today. Let me try one last time.

At http://ruby-talk.org/cgi-bin/scat.rb/ruby/ruby-talk/154898 you gave the
following example to demonstrate how Ruby works internally when doing
load(file,true):

    moulon% cat b.rb
    #!/usr/bin/ruby
    module Anonymous
       module M
          include Anonymous # (X)
          extend Anonymous # (Y)
       end

       include M
    end

If I delete lines (X) and (Y), this script runs without an error.

So, I am trying to ask, why does Ruby forcibly add steps (X) and (Y) in the
first place?

Regards,

Brian.

(ts) #2

So, I am trying to ask, why does Ruby forcibly add steps (X) and (Y) in the
first place?

See [ruby-talk:154956] the script a.rb must give the same result when run
directly with ruby or when it's loaded in an anonymous module.

Guy Decoux