Jan E. wrote in post #1054185:
> Robert Klemme wrote in post #1054170:
>> Do you get that at the calling site or at the definition site?
>
> I get the message when I define the method.

That's how it should be, so one can use Complex et al. without the 
warning.

> Robert Klemme wrote in post #1054170:
>> Jan E. wrote in post #1054047:
>>> Another problem is that constants and methods have different lookup
>>> algorithms, which doesn't allow you to put the conversion method for a
>>> subclass into the same containing module/class (unless you use qualified
>>> names all the time).
>>
>> Can you show an example of what you cannot do?  At the moment I don't
>> see the limitation.

> But when the class is inside a module, you cannot define the method in
> this module and access it in the same way as you access the class:
>
> ####
> module M
>   A = Class.new
>   def self.A()
>     A.new
>   end
>
>   class B
>     def test
>       p A    # this works
>       p A()  # this doesn't
>     end
>   end
> end
>
> b = M::B.new
> b.test
> ####
>
> Of course, there's nothing strange about this behaviour. Methods simply
> cannot access "outer methods". But in this context, I find the different
> lookup algorithms counterintutive. You'd have to qualify the method name
> or define it in a different place (like the top level).

Right.  Thanks for the example!  I agree, that's not intuitive.  But 
given that there are just a few uppercase methods which are intended as 
convenience for users and are mostly (only?) defined in the core lib it 
doesn't bother me too much.

Kind regards

robert

-- 
Posted via http://www.ruby-forum.com/.