[#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:03833] Re: Order of overwriting

From: Aleksi Niemel<aleksi.niemela@...>
Date: 2000-07-05 15:10:29 UTC
List: ruby-talk #3833
> When you include a module in a class, you've affectively making that
> module a parent of the class[1]. As such, it gets inserted between the
> class and the class' original parent:
> 
>       Bar  -->  Zak
> 
>    "include Foo"
> 
>       Bar  -->  Foo --> Zak
> 
>    "include Foo_update"
> 
>       Bar  -->  Foo_update --> Foo --> Zak

Really clear! Thank you.

Now I just have to give some time for my mental model to adjust. It just got
used to the idea the Ruby reads source and processes it as it goes, like:

puts "foo"         # first seen
class Foo          # second thing to see, transfers the interpreter to 
                   # here-comes-a-class-definiton state
  def foo          # changes to a here-comes-a-method-definition state
    puts "bar"     # adds some code to Foo#foo
  end
end

Now I think it will change into:

class Foo          # change to a here-comes-a-class-definition(-remember-
                   # to-scan-through-the-definition-first)
  def foo
  end
  include "Bar"    # whee, here we have it, now we can start to read method
                   # definitions
end

So kind of two pass thing. But I think I'm that flexible, I can learn one
more twist :).

	- Aleksi

In This Thread

Prev Next