[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.ruby

Some wierd Module#append_features behavior

Brian Mitchell

10/5/2006 11:04:00 PM

I couldn't quite figure this out... I am either missing something (I
hope) or there is a small bug:

Module === Module #=> true
Module === Module.new #=> true

af = Module.instance_method(:append_features)

af.bind(Module.new).call(Module) # ok
af.bind(Module.new).call(Module.new) # ok
af.bind(Module).call(Module) # ok
af.bind(Module).call(Module.new) # error!

TypeError: wrong argument type Class (expected Module)

I am kind of puzzled by this... any ideas?

Brian.

4 Answers

Brian Mitchell

10/5/2006 11:19:00 PM

0

On 10/5/06, Brian Mitchell <binary42@gmail.com> wrote:
> I couldn't quite figure this out... I am either missing something (I
> hope) or there is a small bug:
>
> Module === Module #=> true
> Module === Module.new #=> true
>
> af = Module.instance_method(:append_features)
>
> af.bind(Module.new).call(Module) # ok
> af.bind(Module.new).call(Module.new) # ok
> af.bind(Module).call(Module) # ok
> af.bind(Module).call(Module.new) # error!
>
> TypeError: wrong argument type Class (expected Module)
>
> I am kind of puzzled by this... any ideas?

To be more specific, the third "ok" is unexpected if the fourth is not
going to work (which went as I expected).

Brian.

Yukihiro Matsumoto

10/6/2006 4:03:00 AM

0

Hi,

In message "Re: Some wierd Module#append_features behavior"
on Fri, 6 Oct 2006 08:04:27 +0900, "Brian Mitchell" <binary42@gmail.com> writes:

|af.bind(Module).call(Module.new) # error!
|
|TypeError: wrong argument type Class (expected Module)
|
|I am kind of puzzled by this... any ideas?

append_feature tried to append features in Module to a module from
Module.new, but Module itself is a class, not module.

matz.

Brian Mitchell

10/6/2006 2:06:00 PM

0

On 10/6/06, Yukihiro Matsumoto <matz@ruby-lang.org> wrote:
> Hi,
>
> In message "Re: Some wierd Module#append_features behavior"
> on Fri, 6 Oct 2006 08:04:27 +0900, "Brian Mitchell" <binary42@gmail.com> writes:
>
> |af.bind(Module).call(Module.new) # error!
> |
> |TypeError: wrong argument type Class (expected Module)
> |
> |I am kind of puzzled by this... any ideas?
>
> append_feature tried to append features in Module to a module from
> Module.new, but Module itself is a class, not module.

Yes. I know that part. The odd thing that I should have been more clear on is:

af.bind(Module).call(Module).

Module is a Class is both cases but this one seems to work. I am not sure why.

Brian.

Yukihiro Matsumoto

10/6/2006 3:33:00 PM

0

Hi,

In message "Re: Some wierd Module#append_features behavior"
on Fri, 6 Oct 2006 23:05:41 +0900, "Brian Mitchell" <binary42@gmail.com> writes:

|Yes. I know that part. The odd thing that I should have been more clear on is:
|
|af.bind(Module).call(Module).
|
|Module is a Class is both cases but this one seems to work. I am not sure why.

It is a bug. Thank you for finding it.

matz.