[#3986] Re: Principle of least effort -- another Ruby virtue. — Andrew Hunt <andy@...>

> Principle of Least Effort.

14 messages 2000/07/14

[#4043] What are you using Ruby for? — Dave Thomas <Dave@...>

16 messages 2000/07/16

[#4139] Facilitating Ruby self-propagation with the rig-it autopolymorph application. — Conrad Schneiker <schneik@...>

Hi,

11 messages 2000/07/20

[ruby-talk:03835] Re: Order of overwriting

From: Aleksi Niemel<aleksi.niemela@...>
Date: 2000-07-05 15:58:22 UTC
List: ruby-talk #3835
> A> Now I just have to give some time for my mental model to 
> A> adjust. It just got

>  not really

Thank you! I have to remember this little creature:

> pigeon% ruby -Dtx b.rb

It's the Ruby's dynamic nature which is teasing me :). My mental model seems
to be ok. Now it's time to adapt it to feel well with the real environment.
In that environment Ruby does

class Foo < Bar         # Foo.parents.unshift Bar
  def foo               # Foo.add_method foo       [1]
  end
  include "Zak"         # Foo.parents.unshift Zak
end

[1] here I assumed to be Foo#foo.super=Foo.parents[0]

so when Ruby tries to find a proper method it asks for Foo#foo.super (which
is pointing to Bar#foo). This was my mistake.

Actually the (dynamic) model seems to be

  def Foo#foo.super
    Foo.parents[0]#foo
  end

so the lookup is done dynamically each time. And for performance purposes
Ruby might cache the actual value for Foo#foo.super, and each 'include'
importing the method of same name just updates the cached value. 

Anyway, it's probably better to start think in dynamic terms :). Thanks for
Guy and Dave for interesting and enlightening explanation.

	- Aleksi

In This Thread

Prev Next