[#10492] Ruby 1.8.6 preview3 has been released — "Akinori MUSHA" <knu@...>

Hi,

26 messages 2007/03/04
[#10500] Re: Ruby 1.8.6 preview3 has been released — Hugh Sasse <hgs@...> 2007/03/05

On Mon, 5 Mar 2007, Akinori MUSHA wrote:

[#10507] Dynamic Array#join with block — <noreply@...>

Patches item #9055, was opened at 2007-03-05 19:57

12 messages 2007/03/05
[#10520] Re: [ ruby-Patches-9055 ] Dynamic Array#join with block — Nobuyoshi Nakada <nobu@...> 2007/03/06

Hi,

[#10594] grave bug in 1.8.6's thread implementation — Sylvain Joyeux <sylvain.joyeux@...4x.org>

In ext/thread/thread.c, remove_one leaves the list in an inconsistent state.

15 messages 2007/03/14
[#10596] Re: [PATCH] grave bug in 1.8.6's thread implementation — MenTaLguY <mental@...> 2007/03/14

On Thu, 15 Mar 2007 00:15:57 +0900, Sylvain Joyeux <sylvain.joyeux@m4x.org> wrote:

[#10597] Re: [PATCH] grave bug in 1.8.6's thread implementation — Sylvain Joyeux <sylvain.joyeux@...4x.org> 2007/03/14

> > The fix is in thread-mutex-remove_one.diff.

[#10598] Re: [PATCH] grave bug in 1.8.6's thread implementation — MenTaLguY <mental@...> 2007/03/14

On Thu, 15 Mar 2007 01:19:04 +0900, Sylvain Joyeux <sylvain.joyeux@m4x.org> wrote:

[#10599] Re: [PATCH] grave bug in 1.8.6's thread implementation — Sylvain Joyeux <sylvain.joyeux@...4x.org> 2007/03/14

On Wednesday 14 March 2007 17:29, MenTaLguY wrote:

[#10600] Re: [PATCH] grave bug in 1.8.6's thread implementation — MenTaLguY <mental@...> 2007/03/14

On Thu, 15 Mar 2007 01:48:42 +0900, Sylvain Joyeux <sylvain.joyeux@m4x.org> wrote:

[#10615] Multiton in standard library — TRANS <transfire@...>

Hi--

16 messages 2007/03/15
[#10619] Re: Multiton in standard library — Tom Pollard <tomp@...> 2007/03/16

[#10620] Re: Multiton in standard library — TRANS <transfire@...> 2007/03/16

On 3/15/07, Tom Pollard <tomp@earthlink.net> wrote:

[#10646] Marshal.dump shouldn't complain about singletons if the _dump method is defined — <noreply@...>

Bugs item #9376, was opened at 2007-03-19 15:58

12 messages 2007/03/19
[#10647] Re: [ ruby-Bugs-9376 ] Marshal.dump shouldn't complain about singletons if the _dump method is defined — Urabe Shyouhei <shyouhei@...> 2007/03/19

noreply@rubyforge.org wrote:

[#10648] Re: [ ruby-Bugs-9376 ] Marshal.dump shouldn't complain about singletons if the _dump method is defined — Sylvain Joyeux <sylvain.joyeux@...4x.org> 2007/03/19

On Monday 19 March 2007 18:01, Urabe Shyouhei wrote:

[#10651] Re: [ ruby-Bugs-9376 ] Marshal.dump shouldn't complain about singletons if the _dump method is defined — Yukihiro Matsumoto <matz@...> 2007/03/19

Hi,

[#10665] Re: [ ruby-Bugs-9376 ] Marshal.dump shouldn't complain about singletons if the _dump method is defined — "Chris Carter" <cdcarter@...> 2007/03/20

On 3/19/07, Yukihiro Matsumoto <matz@ruby-lang.org> wrote:

[#10712] Ruby Method Signatures (was Re: Multiton in standard library) — "Rick DeNatale" <rick.denatale@...>

On 3/19/07, TRANS <transfire@gmail.com> wrote:

10 messages 2007/03/21
[#10715] Re: Ruby Method Signatures (was Re: Multiton in standard library) — Jos Backus <jos@...> 2007/03/22

On 3/19/07, TRANS <transfire@gmail.com> wrote:

[#10798] Virtual classes and 'real' classes -- why? — "John Lam (CLR)" <jflam@...>

I was wondering if someone could help me understand why there's a parallel =

12 messages 2007/03/28
[#10799] Re: Virtual classes and 'real' classes -- why? — MenTaLguY <mental@...> 2007/03/28

On Thu, 29 Mar 2007 04:44:16 +0900, "John Lam (CLR)" <jflam@microsoft.com> wrote:

Is there interest in this? : get object from its object-specific class?

From: "Rick DeNatale" <rick.denatale@...>
Date: 2007-03-15 22:51:42 UTC
List: ruby-core #10616
The following is the culmination of a discussion on ruby-talk from a
few days ago.

Someone asked if there was a way to find the instance of a singleton
class if you only had the class.  After positing a solution using
ObjectSpace.each_object, I then wrote a small extension to get it via
the hidden __attached__ instance variable.

I was then asked to submit it to ruby-core, although I'm not sure
whether it's a problem which needs to be addressed in the core.

But just in case here's the discussion.  If there's interest, I could
come up with a patch for 1.8.5, 1.8.6, and maybe 1.9.

On 3/13/07, Trans <transfire@gmail.com> wrote:
>
>
> On Mar 13, 1:56 pm, "Rick DeNatale" <rick.denat...@gmail.com> wrote:
> > On 3/13/07, Trans <transf...@gmail.com> wrote:
> > Two approaches with a benchmark.
> >
> > And as I surmised, there's a really quick way to do this with a
> > relatively simple extension (at least for ruby1.8, I haven't looked at
> > this on 1.9).
> >
> > rick@frodo:/public/rubyscripts/getsinginst$ cat get_sing_inst.c
> > #include "ruby.h"
> >
> > static VALUE singleton_instance(VALUE obj)
> > {
> >   if (BUILTIN_TYPE(obj) == T_CLASS && FL_TEST(obj, FL_SINGLETON)) {
> >       return rb_iv_get(obj, "__attached__");
> >   }
> >   rb_raise(rb_eTypeError, "not a singleton class");
> >
> > }
> >
> > void Init_get_sing_inst()
> > {
> >   rb_define_method(rb_cClass, "singleton_instance", singleton_instance, 0);
> >
> > }
> >
> > rick@frodo:/public/rubyscripts/getsinginst$ cat gsi.rb
> > require 'get_sing_inst'
> >
> > h = {:a => 1}
> > sc = class << h
> >     def foo
> >     end
> >
> >     self
> >    end
> >
> > p sc.singleton_instance
> > p sc.singleton_instance.object_id == h.object_id
> >
> > def instance_of_singleton_class_1(sc)
> >     ObjectSpace.each_object(sc) do |obj|
> >       return obj
> >     end
> >   end
> >
> >   def instance_of_singleton_class_2(sc)
> >     obj = nil
> >     sc.class_eval do
> >       if instance_methods(false).include?("singleton_method_added")
> >         org = instance_method("singleton_method_added")
> >         remove_method("singleton_method_added")
> >       end
> >       define_method("singleton_method_added") do |m|
> >         obj = self
> >       end
> >       remove_method("singleton_method_added")
> >       define_method("singleton_method_added", org) if org
> >     end
> >     obj
> >   end
> >
> > require "benchmark"
> >
> >   Benchmark.bmbm do |bm|
> >     bm.report "ObjectSpace" do
> >       10000.times do instance_of_singleton_class_1(sc) end
> >     end
> >     bm.report "singleton_method_added" do
> >       10000.times do instance_of_singleton_class_2(sc) end
> >     end
> >     bm.report "primitive" do
> >       10000.times do sc.singleton_instance end
> >     end
> >   end
> >
> > And now for the benchmark results,  note that I'm doing 10 times as
> > many interations as Trans did, 10000 vs. 1000, the primitive is on the
> > order of two orders of magnitude faster than either of the other
> > approaches.
>
> Actually, you mean Pit. He did the benchmarks. This is definitely the
> way to do it right though. I would submit this to ruby-core mailing
> list and see how it takes over there.
>
> T.
>
>
>


-- 
Rick DeNatale

My blog on Ruby
http://talklikeaduck.denhaven2.com/

IPMS/USA Region 12 Coordinator
http://ipmsr12.denhaven2.com/

Visit the Project Mercury Wiki Site
http://www.mercuryspacecraft.com/

In This Thread

Prev Next