"cyclic include" error inside anonymous module

Discussion in 'Ruby' started by Brian Candler, Sep 4, 2005.

  1. I'm looking for an explanation of the following:

    $ ruby -v
    ruby 1.8.2 (2004-12-25) [i386-freebsd5]

    $ cat ruby3.rb
    load 'ruby4.rb', true

    $ cat ruby4.rb
    module M
    end
    include M

    $ ruby ruby3.rb
    /ruby4.rb:3:in `append_features': cyclic include detected (ArgumentError)
    from ./ruby4.rb:3:in `include'
    from ./ruby4.rb:3
    from ruby3.rb:1:in `load'
    from ruby3.rb:1

    My understanding of load(filename,true) was that the code would be wrapped
    inside an anonymous module, which I thought of as being like

    module FOOBARrandom123456
    ... code goes here
    end

    But that doesn't explain the 'cyclic include' which running ruby3.rb gives
    (but not running ruby4.rb by itself)

    Thanks,

    Brian.
     
    Brian Candler, Sep 4, 2005
    #1
    1. Advertising

  2. Brian Candler

    ts Guest

    >>>>> "B" == Brian Candler <> writes:

    B> load 'ruby4.rb', true

    ruby create an anonymous module (wrapper) to make the load and protect
    (i.e. clone) main (ruby_top_self)

    B> module M

    each time a module is created, ruby include/extend the wrapper in it.

    B> end

    B> include M

    when you make the include, it detect the wrapper (it's in module).
    Consequence :

    B> ./ruby4.rb:3:in `append_features': cyclic include detected (ArgumentError)


    Guy Decoux
     
    ts, Sep 4, 2005
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Andreas Neudecker
    Replies:
    4
    Views:
    320
    Andreas Neudecker
    Aug 9, 2004
  2. Reporter
    Replies:
    3
    Views:
    496
    Mike Schilling
    May 12, 2007
  3. David Resnick
    Replies:
    7
    Views:
    511
    =?iso-2022-kr?q?=1B=24=29CHarald_van_D=0E=29=26=0F
    Oct 29, 2007
  4. johng
    Replies:
    7
    Views:
    139
    johng
    May 25, 2005
  5. Replies:
    1
    Views:
    239
Loading...

Share This Page