ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
* [1.8] alias
@ 2003-06-01 10:09 ts
  2003-06-02  2:16 ` Yukihiro Matsumoto
  0 siblings, 1 reply; 6+ messages in thread
From: ts @ 2003-06-01 10:09 UTC (permalink / raw
  To: ruby-core


 I still don't understand alias, normal this ?


svg% cat b.rb
#!./ruby -v

module M
   def init(a)
      p "M #{a}"
   end

end

class A
   include M

   def init(a)
      p "A : #{a}"
      super 12
   end
end

module N
   def init(a)
      p "N #{a}"
      super 12
   end
   alias_method :abc, :init
end

class B < A
   include N
   def init(a)
      p "B#init"
      super
   end

   def abc(b)
      p "abc"
      super
   end
end

puts "======================="
b = B.new
b.init(24)
puts "======================="
b.abc(36)
svg% 

svg% b.rb
ruby 1.8.0 (2003-06-01) [i686-linux]
=======================
"B#init"
"N 24"
"A : 12"
"M 12"
=======================
"abc"
"N 36"
./b.rb:22:in `abc': method `init' called on terminated object (0x40099038) (NotImplementedError)
        from ./b.rb:36:in `abc'
        from ./b.rb:44
svg% 


Guy Decoux

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [1.8] alias
  2003-06-01 10:09 [1.8] alias ts
@ 2003-06-02  2:16 ` Yukihiro Matsumoto
  2003-06-02 13:33   ` ts
  0 siblings, 1 reply; 6+ messages in thread
From: Yukihiro Matsumoto @ 2003-06-02  2:16 UTC (permalink / raw
  To: ruby-core

Hi,

In message "[1.8] alias"
    on 03/06/01, ts <decoux@moulon.inra.fr> writes:

| I still don't understand alias, normal this ?

No.  It's a bug.  Will be fixed soon.

							matz.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [1.8] alias
  2003-06-02  2:16 ` Yukihiro Matsumoto
@ 2003-06-02 13:33   ` ts
  2003-06-03  0:59     ` Yukihiro Matsumoto
  0 siblings, 1 reply; 6+ messages in thread
From: ts @ 2003-06-02 13:33 UTC (permalink / raw
  To: ruby-core; +Cc: ruby-core

>>>>> "Y" == Yukihiro Matsumoto <matz@ruby-lang.org> writes:

Y> No.  It's a bug.  Will be fixed soon.

 Normal ?

svg% cat b.rb
#!./ruby -v
module M
   def init
      p "init"
   end

   alias abc init
   module_function :abc
end

M.abc
svg% 

svg% b.rb
ruby 1.8.0 (2003-06-02) [i686-linux]
./b.rb:11: M is not included in Module (TypeError)
svg% 


Guy Decoux

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [1.8] alias
  2003-06-02 13:33   ` ts
@ 2003-06-03  0:59     ` Yukihiro Matsumoto
  2003-06-03 12:48       ` ts
  0 siblings, 1 reply; 6+ messages in thread
From: Yukihiro Matsumoto @ 2003-06-03  0:59 UTC (permalink / raw
  To: ruby-core

Hi,

In message "Re: [1.8] alias"
    on 03/06/02, ts <decoux@moulon.inra.fr> writes:

|>>>>> "Y" == Yukihiro Matsumoto <matz@ruby-lang.org> writes:
|
|Y> No.  It's a bug.  Will be fixed soon.
|
| Normal ?

No, I was too eager to resolve inheritance line problem.  I will move
adjustment to rb_call_super().

							matz.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [1.8] alias
  2003-06-03  0:59     ` Yukihiro Matsumoto
@ 2003-06-03 12:48       ` ts
  2003-06-03 13:24         ` Yukihiro Matsumoto
  0 siblings, 1 reply; 6+ messages in thread
From: ts @ 2003-06-03 12:48 UTC (permalink / raw
  To: ruby-core; +Cc: ruby-core

>>>>> "Y" == Yukihiro Matsumoto <matz@ruby-lang.org> writes:

Y> No, I was too eager to resolve inheritance line problem.  I will move
Y> adjustment to rb_call_super().

 Well, I like the DRY principle but certainly I don't really understand how
 alias work 

svg% cat b.rb
#!./ruby -v
module M
   def init(a)
      p "M #{a}"
   end

end

class A
   include M

   def init(a)
      p "A : #{a}"
      super 12
   end
end

module N
   def init(a)
      p "N #{a}"
      super 12
   end
   alias_method :abc, :init
end

class B < A
   include N
   def init(a)
      p "B#init"
      super
   end

   def abc(b)
      p "abc"
      super
   end
end

puts "======================="
b = B.new
b.init(24)
puts "======================="
b.abc(36)
svg% 

svg% b.rb
ruby 1.8.0 (2003-06-03) [i686-linux]
=======================
"B#init"
"N 24"
"A : 12"
"M 12"
=======================
"abc"
"N 36"
./b.rb:21:in `abc': super: no superclass method `abc' (NoMethodError)
        from ./b.rb:35:in `abc'
        from ./b.rb:43
svg% 


Guy Decoux

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [1.8] alias
  2003-06-03 12:48       ` ts
@ 2003-06-03 13:24         ` Yukihiro Matsumoto
  0 siblings, 0 replies; 6+ messages in thread
From: Yukihiro Matsumoto @ 2003-06-03 13:24 UTC (permalink / raw
  To: ruby-core

Hi,

In message "Re: [1.8] alias"
    on 03/06/03, ts <decoux@moulon.inra.fr> writes:

|Y> No, I was too eager to resolve inheritance line problem.  I will move
|Y> adjustment to rb_call_super().
|
| Well, I like the DRY principle but certainly I don't really understand how
| alias work 

Eban also mentioned a bug in my fix.  I will cover it.

							matz.

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2003-06-03 13:21 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-06-01 10:09 [1.8] alias ts
2003-06-02  2:16 ` Yukihiro Matsumoto
2003-06-02 13:33   ` ts
2003-06-03  0:59     ` Yukihiro Matsumoto
2003-06-03 12:48       ` ts
2003-06-03 13:24         ` Yukihiro Matsumoto

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).