Hey, The next REPL session works fine in MRI but in IR it throws an error:>>> str = "sss"=> "sss">>> ObjectSpace.each_object(String) { |x| puts x }d:\IronRuby\GitRepository2\ironruby\Merlin\Main\Languages\Ruby\Libraries.LCA_RESTRICTED\Builtins\ObjectSpace.cs:37:in `each_object'': each_object only supported for objects of type Class or Module (RuntimeError) from :0 I looked a bit into it and IR identifies String as a descendant of Object and not Module as it expects. This problem makes it impossible to run each_object on Numeric as well (and I guess more types that are mapped directly to CLR types). Should I create a bug? Thanks! Shay. -- -------------------------------------------------- Shay Friedman Author of IronRuby Unleashed http://www.IronShay.com Follow me: http://twitter.com/ironshay
This is by design. We don''t support enumerating objects that are not modules. A string instance is not a module. Why do you need to enumerate all allocated strings? Tomas -----Original Message----- From: ironruby-core-bounces at rubyforge.org [mailto:ironruby-core-bounces at rubyforge.org] On Behalf Of Shay Friedman Sent: Sunday, October 25, 2009 1:26 PM To: ironruby-core Subject: [Ironruby-core] Something''s wrong with ObjectSpace Hey, The next REPL session works fine in MRI but in IR it throws an error:>>> str = "sss"=> "sss">>> ObjectSpace.each_object(String) { |x| puts x }d:\IronRuby\GitRepository2\ironruby\Merlin\Main\Languages\Ruby\Libraries.LCA_RESTRICTED\Builtins\ObjectSpace.cs:37:in `each_object'': each_object only supported for objects of type Class or Module (RuntimeError) from :0 I looked a bit into it and IR identifies String as a descendant of Object and not Module as it expects. This problem makes it impossible to run each_object on Numeric as well (and I guess more types that are mapped directly to CLR types). Should I create a bug? Thanks! Shay. -- -------------------------------------------------- Shay Friedman Author of IronRuby Unleashed http://www.IronShay.com Follow me: http://twitter.com/ironshay _______________________________________________ Ironruby-core mailing list Ironruby-core at rubyforge.org http://rubyforge.org/mailman/listinfo/ironruby-core
I don''t have a specific need for that right now. However, it does sound logical to me that you''d want to get all the strings in your application. It becomes even more reasonable when you run each_object with Thread, to find out all defined. This doesn''t work as well. But, this is not the most used class out there so I IronRuby will continue to ROCK despite that. Thanks for the reply Tomas, Shay. On Mon, Oct 26, 2009 at 1:00 AM, Tomas Matousek < Tomas.Matousek at microsoft.com> wrote:> This is by design. We don''t support enumerating objects that are not > modules. A string instance is not a module. > Why do you need to enumerate all allocated strings? > > Tomas > > -----Original Message----- > From: ironruby-core-bounces at rubyforge.org [mailto: > ironruby-core-bounces at rubyforge.org] On Behalf Of Shay Friedman > Sent: Sunday, October 25, 2009 1:26 PM > To: ironruby-core > Subject: [Ironruby-core] Something''s wrong with ObjectSpace > > Hey, > > The next REPL session works fine in MRI but in IR it throws an error: > >>> str = "sss" > => "sss" > >>> ObjectSpace.each_object(String) { |x| puts x } > > d:\IronRuby\GitRepository2\ironruby\Merlin\Main\Languages\Ruby\Libraries.LCA_RESTRICTED\Builtins\ObjectSpace.cs:37:in > `each_object'': each_object only supported for objects of type Class or > Module (RuntimeError) > from :0 > > I looked a bit into it and IR identifies String as a descendant of Object > and not Module as it expects. This problem makes it impossible to run > each_object on Numeric as well (and I guess more types that are mapped > directly to CLR types). > > Should I create a bug? > > Thanks! > Shay. > -- > -------------------------------------------------- > Shay Friedman > Author of IronRuby Unleashed > http://www.IronShay.com > Follow me: http://twitter.com/ironshay > _______________________________________________ > Ironruby-core mailing list > Ironruby-core at rubyforge.org > http://rubyforge.org/mailman/listinfo/ironruby-core > > _______________________________________________ > Ironruby-core mailing list > Ironruby-core at rubyforge.org > http://rubyforge.org/mailman/listinfo/ironruby-core >-- -------------------------------------------------- Shay Friedman Author of IronRuby Unleashed http://www.IronShay.com Follow me: http://twitter.com/ironshay -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/ironruby-core/attachments/20091026/ba9efb45/attachment-0001.html>
Such feature would incur a significant performance hit to all applications. If you really need to get all instances of some class you can e.g. monkey-patch its initialize method and store the instances in a (weak) list. Although we could provide a command line option that would allow us to match MRI''s semantics of each_object precisely, I don''t see a strong use case for such feature. All use cases I have seen so far could be implemented in much more efficient way that doesn''t rely on ObjectSpace. Tomas From: ironruby-core-bounces at rubyforge.org [mailto:ironruby-core-bounces at rubyforge.org] On Behalf Of Shay Friedman Sent: Sunday, October 25, 2009 10:10 PM To: ironruby-core at rubyforge.org Subject: Re: [Ironruby-core] Something''s wrong with ObjectSpace I don''t have a specific need for that right now. However, it does sound logical to me that you''d want to get all the strings in your application. It becomes even more reasonable when you run each_object with Thread, to find out all defined. This doesn''t work as well. But, this is not the most used class out there so I IronRuby will continue to ROCK despite that. Thanks for the reply Tomas, Shay. On Mon, Oct 26, 2009 at 1:00 AM, Tomas Matousek <Tomas.Matousek at microsoft.com<mailto:Tomas.Matousek at microsoft.com>> wrote: This is by design. We don''t support enumerating objects that are not modules. A string instance is not a module. Why do you need to enumerate all allocated strings? Tomas -----Original Message----- From: ironruby-core-bounces at rubyforge.org<mailto:ironruby-core-bounces at rubyforge.org> [mailto:ironruby-core-bounces at rubyforge.org<mailto:ironruby-core-bounces at rubyforge.org>] On Behalf Of Shay Friedman Sent: Sunday, October 25, 2009 1:26 PM To: ironruby-core Subject: [Ironruby-core] Something''s wrong with ObjectSpace Hey, The next REPL session works fine in MRI but in IR it throws an error:>>> str = "sss"=> "sss">>> ObjectSpace.each_object(String) { |x| puts x }d:\IronRuby\GitRepository2\ironruby\Merlin\Main\Languages\Ruby\Libraries.LCA_RESTRICTED\Builtins\ObjectSpace.cs:37:in `each_object'': each_object only supported for objects of type Class or Module (RuntimeError) from :0 I looked a bit into it and IR identifies String as a descendant of Object and not Module as it expects. This problem makes it impossible to run each_object on Numeric as well (and I guess more types that are mapped directly to CLR types). Should I create a bug? Thanks! Shay. -- -------------------------------------------------- Shay Friedman Author of IronRuby Unleashed http://www.IronShay.com Follow me: http://twitter.com/ironshay _______________________________________________ Ironruby-core mailing list Ironruby-core at rubyforge.org<mailto:Ironruby-core at rubyforge.org> http://rubyforge.org/mailman/listinfo/ironruby-core _______________________________________________ Ironruby-core mailing list Ironruby-core at rubyforge.org<mailto:Ironruby-core at rubyforge.org> http://rubyforge.org/mailman/listinfo/ironruby-core -- -------------------------------------------------- Shay Friedman Author of IronRuby Unleashed http://www.IronShay.com Follow me: http://twitter.com/ironshay -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/ironruby-core/attachments/20091026/6420c937/attachment.html>