[#18121] [Ruby 1.8.7 - Bug #405] (Open) ssl.rb:31: [BUG] Bus Error — Anonymous <redmine@...>

Issue #405 has been reported by Anonymous.

14 messages 2008/08/04

[#18130] Re: New array methods cycle, choice, shuffle (plus bug in cycle) — Brian Candler <B.Candler@...>

> Seriously though... Array.first is a noun.

10 messages 2008/08/05

[#18319] NEW Command: absolute_path() -- — "C.E. Thornton" <admin@...>

Core,

14 messages 2008/08/16
[#18321] Re: NEW Command: absolute_path() -- — Yukihiro Matsumoto <matz@...> 2008/08/18

Hi,

[#18381] [Bug #496] DRb.start_service(nil) is very slow — Hongli Lai <redmine@...>

Bug #496: DRb.start_service(nil) is very slow

11 messages 2008/08/25

[ruby-core:18120] Re: module inclusion and method definitions

From: Jens Wille <jens.wille@...>
Date: 2008-08-04 10:21:24 UTC
List: ruby-core #18120
hi j辿r辿my!

J辿r辿my Zurcher [2008-08-03 22:48]:
>     module M2; end
>     class C2; include M2; end
>     module M2; def m; puts "hello world" end; end
>     C2.new.m
> 
>     >> hello world
> 
>     module M5; def m; puts "hello world" end; end
>     module M4; include M5; end
>     class C4; include M4; end
>     C4.new.m
> 
>     >> hello world
> 
>     module M7; def m; puts "hello world" end; end
>     module M6; end
>     class C5; include M6; end
>     module M6 include M7; end
>     C5.new.m
> 
>     >> test.rb:13: undefined method `m' for #<C5:0xb7ca02bc> (NoMethodError)
> 
> obviously M7 is not found in the ansestors of C5, has show by the ancestors
> method.
as i see it, that's actually the point. when you include some module
M in a class C, M and all its ancestors will be added to C's module
hierarchy (where methods and constants are looked up). but there's
no further connection or coupling between the two hierarchies.
adding to M's hierarchy doesn't affect C's in any way. even removing
M has no consequences for C at that point ;-)

the only thing you could probably do is something along the lines of:

  module M
    def m; 'm'; end

    def self.included(base)
      if receivers = base.instance_variable_get(:@receivers)
        receivers.each { |r| r.send(:include, self) }
      end
    end
  end

  module N
    @receivers = []

    def self.included(base); @receivers << base; end
  end

  class C; include N; end

  C.new.m  #=> undefined method `m' for #<C:0x2b5946f01818>

  module N; include M; end

  C.new.m  #=> "m"

cheers
jens

-- 
Jens Wille, Dipl.-Bibl. (FH)
prometheus - Das verteilte digitale Bildarchiv f端r Forschung & Lehre
Kunsthistorisches Institut der Universit辰t zu K旦ln
Albertus-Magnus-Platz, D-50923 K旦ln
Tel.: +49 (0)221 470-6668, E-Mail: jens.wille@uni-koeln.de
http://www.prometheus-bildarchiv.de/

In This Thread

Prev Next