[#13161] hacking on the "heap" implementation in gc.c — Lloyd Hilaiel <lloyd@...>

Hi all,

16 messages 2007/11/01

[#13182] Thinking of dropping YAML from 1.8 — Urabe Shyouhei <shyouhei@...>

Hello all.

14 messages 2007/11/03

[#13315] primary encoding and source encoding — David Flanagan <david@...>

I've got a couple of questions about the handling of primary encoding.

29 messages 2007/11/08
[#13331] Re: primary encoding and source encoding — Yukihiro Matsumoto <matz@...> 2007/11/09

Hi,

[#13368] method names in 1.9 — "David A. Black" <dblack@...>

Hi --

61 messages 2007/11/10
[#13369] Re: method names in 1.9 — Yukihiro Matsumoto <matz@...> 2007/11/10

Hi,

[#13388] Re: method names in 1.9 — Charles Oliver Nutter <charles.nutter@...> 2007/11/11

Yukihiro Matsumoto wrote:

[#13403] Re: method names in 1.9 — "Austin Ziegler" <halostatue@...> 2007/11/11

On 11/11/07, Charles Oliver Nutter <charles.nutter@sun.com> wrote:

[#13410] Re: method names in 1.9 — David Flanagan <david@...> 2007/11/11

Austin Ziegler wrote:

[#13413] Re: method names in 1.9 — Charles Oliver Nutter <charles.nutter@...> 2007/11/11

David Flanagan wrote:

[#13423] Re: method names in 1.9 — Jordi <mumismo@...> 2007/11/12

Summing it up:

[#13386] Re: method names in 1.9 — Trans <transfire@...> 2007/11/11

[#13391] Re: method names in 1.9 — Matthew Boeh <mboeh@...> 2007/11/11

On Sun, Nov 11, 2007 at 05:50:18PM +0900, Trans wrote:

[#13457] mingw rename — "Roger Pack" <rogerpack2005@...>

Currently for different windows' builds, the names for RUBY_PLATFORM

13 messages 2007/11/13

[#13485] Proposal: Array#walker — Wolfgang Nádasi-Donner <ed.odanow@...>

Good morning all together!

23 messages 2007/11/14
[#13486] Re: Proposal: Array#walker — Wolfgang Nádasi-Donner <ed.odanow@...> 2007/11/14

A nicer version may be...

[#13488] Re: Proposal: Array#walker — Trans <transfire@...> 2007/11/14

[#13495] Re: Proposal: Array#walker — Trans <transfire@...> 2007/11/14

[#13498] state of threads in 1.9 — Jordi <mumismo@...>

Are Threads mapped to threads on the underlying operating system in

30 messages 2007/11/14
[#13519] Re: state of threads in 1.9 — "Bill Kelly" <billk@...> 2007/11/14

[#13526] Re: state of threads in 1.9 — Eric Hodel <drbrain@...7.net> 2007/11/14

On Nov 14, 2007, at 11:18 , Bill Kelly wrote:

[#13528] test/unit and miniunit — Ryan Davis <ryand-ruby@...>

When is the 1.9 freeze?

17 messages 2007/11/14

[#13564] Thoughts about Array#compact!, Array#flatten!, Array#reject!, String#strip!, String#capitalize!, String#gsub!, etc. — Wolfgang Nádasi-Donner <ed.odanow@...>

Good evening all together!

53 messages 2007/11/15
[#13575] Re: Thoughts about Array#compact!, Array#flatten!, Array#reject!, String#strip!, String#capitalize!, String#gsub!, etc. — "Nikolai Weibull" <now@...> 2007/11/15

On Nov 15, 2007 8:14 PM, Wolfgang N=E1dasi-Donner <ed.odanow@wonado.de> wro=

[#13578] Re: Thoughts about Array#compact!, Array#flatten!, Array#reject!, String#strip!, String#capitalize!, String#gsub!, etc. — Michael Neumann <mneumann@...> 2007/11/16

Nikolai Weibull schrieb:

[#13598] wondering about #tap (was: Re: Thoughts about Array#compact!, Array#flatten!, Array#reject!, String#strip!, String#capitalize!, String#gsub!, etc.) — "David A. Black" <dblack@...> 2007/11/16

Hi --

[#13605] Re: wondering about #tap (was: Re: Thoughts about Array#compact!, Array#flatten!, Array#reject!, String#strip!, String#capitalize!, String#gsub!, etc.) — Trans <transfire@...> 2007/11/16

[#13612] Re: wondering about #tap (was: Re: Thoughts about Array#compact!, Array#flatten!, Array#reject!, String#strip!, String#capitalize!, String#gsub!, etc.) — "David A. Black" <dblack@...> 2007/11/16

Hi --

[#13624] Re: wondering about #tap (was: Re: Thoughts about Array#compact!, Array#flatten!, Array#reject!, String#strip!, String#capitalize!, String#gsub!, etc.) — "Nikolai Weibull" <now@...> 2007/11/16

On Nov 16, 2007 12:40 PM, David A. Black <dblack@rubypal.com> wrote:

[#13632] Re: wondering about #tap — David Flanagan <david@...> 2007/11/16

David A. Black wrote:

[#13634] Re: wondering about #tap — "David A. Black" <dblack@...> 2007/11/16

Hi --

[#13636] Re: wondering about #tap — "Rick DeNatale" <rick.denatale@...> 2007/11/16

On Nov 16, 2007 12:40 PM, David A. Black <dblack@rubypal.com> wrote:

[#13637] Re: wondering about #tap — murphy <murphy@...> 2007/11/16

Rick DeNatale wrote:

[#13640] Re: wondering about #tap — Wolfgang Nádasi-Donner <ed.odanow@...> 2007/11/16

murphy schrieb:

[#13614] Suggestion for native thread tests — "Eust痃uio Rangel" <eustaquiorangel@...>

Hi!

12 messages 2007/11/16

[#13685] Problems with \M-x in utf-8 encoded strings — Wolfgang Nádasi-Donner <ed.odanow@...>

Hi!

11 messages 2007/11/18

[#13741] retry semantics changed — Dave Thomas <dave@...>

In 1.8, I could write:

46 messages 2007/11/23
[#13742] Re: retry semantics changed — "Brian Mitchell" <binary42@...> 2007/11/23

On Nov 23, 2007 12:06 PM, Dave Thomas <dave@pragprog.com> wrote:

[#13743] Re: retry semantics changed — Dave Thomas <dave@...> 2007/11/23

[#13746] Re: retry semantics changed — Yukihiro Matsumoto <matz@...> 2007/11/23

Hi,

[#13747] Re: retry semantics changed — Dave Thomas <dave@...> 2007/11/23

[#13748] Re: retry semantics changed — Yukihiro Matsumoto <matz@...> 2007/11/23

Hi,

[#13749] Re: retry semantics changed — Dave Thomas <dave@...> 2007/11/23

Proposal of a new operator for Method and Proc

From: Jordi <mumismo@...>
Date: 2007-11-08 09:08:04 UTC
List: ruby-core #13289
Hello, this email is long but I hope you to read it. I think it is worth it.
I think I found a powerful new operator for ruby that can make the
language even better.
 If you want to just read about that go to ==The cool stuff== section below.


== The search for events ==

First, the classes below are not tested and I'm just a beginner, some
errors are took for granted. Won't affect my discourse.
I wanted to implement a timer, looking in google the first thing you
get is something like this:

class Timer

 def start (timeout)
   th = Thread.new do
     loop do
       # work done by the timer
       sleep(timeout)
     end
   end
 end
end

Let's suppose I'm only using the timer to implement some kind of counter.
Cool, BUT I would like that the work of the timer be only time
related! and the counter be in its relevant class.
Also I may want to reuse this class.


So I thought about something like this

class Timer

 def initialize (*arguments)
   connections=[]
   @arguments=arguments
 end
 def register_work ( pointer)
   connections += pointer
 end
 def deregister_work (pointer)
   connections -= pointer
 end
 def deregister_all
   connections =[]
 end
 def list
   connections.each { |l| puts "#{l}" }
 end

 def start (timeout)
   th = Thread.new do
     loop do
       # work done by the timer
       connections.each { |l| l.call(*@arguments) }
       sleep (timeout)
     end
   end
 end

end

I wrote pointer, I meant for instance Counter.count()

This class is much more general and powerful.
The work is done in the relevant classes and not inside the timer
Also, we can register as many connected classes as we want.


Seeing that this is Good (tm) I thought about how can I make any class use this.
Of course I can make a class with the register, deregister and call
thing and mixin it.

But Wouldn't be could that these encapsulated connections are
supported natively by ruby?

About benefits of this scheme:
http://doc.trolltech.com/4.3/signalsandslots.html

About a comparison of implementations (going straight to the
comparison table is better):
http://scottcollins.net/articles/a-deeper-look-at-signals-and-slots.html


==The cool stuff ==

I thought about how to get this feature implemented without polluting
the most basic class of Ruby.
I think that the most powerful and less polluting way is adding a new
operator to Method and Proc.


Example.
I have a class Page, a class Timer and a class Counter.  The Page
instance is the parent of both instances of Timer and Counter.

class Page

 def initialize
   counter = Counter.new
   t=Timer.new

   t.timeout -> counter.update
   counter.overrun -> show_error

 end

end

Some notes:
We connect the timeout of the timer with the update of the counter.
We connect the overrun of the counter with an error show by the page.
The Timer whenever it timeouts, it just ... call to its .timeout() method.

Note that the Timer class does not need to be modified to make
something new (update the counter) . It is a real isolated software
component.
The same goes to the counter, it overruns and let the world know about
it. That is its job. Don't need to know about the Page having and
error.

I  proposed "->" in my ignorance. It may appear as a redirect rather
than "something you add". Surely something else is better.



With this scheme, we have a general and easy , cool, even rubyish way
to connect to events and to connect code arbitrarily to any class
method!
For instance, we need to make some clean up each time we call to
File.close() (whatever reason)
Previous simple way

def close (file)
 file.close
 @filesOpened -= 1
end

new way (in the construstor):

file.close -> {  @filesOpened -= 1 }

{  @filesOpened -= 1 } will become a Proc called when file.close
finish. See that the implementation in C should be efficient (a list
of pointers to functions)

Now suppose that you load a new plugin that also need to do some
cleanup when the file open by the main class is closed. When loaded it
will add itself whatever it needs for itself.


i feel my examples are not very good... sorry.


== Summary ==

This addition to the language isolates software components and creates
a new very powerful construction at a very low cost.




--
Jordi Polo (ジョルデイ ポロ)
奈良先端科学技術大学院大学 情報科学研究科
自然言語処理学講座 D1

In This Thread

Prev Next