From jflam at microsoft.com Sat Dec 1 00:37:30 2007 From: jflam at microsoft.com (John Lam (DLR)) Date: Fri, 30 Nov 2007 21:37:30 -0800 Subject: [Ironruby-core] Claiming IO Message-ID: <372109E149E8084D8E6C7D9CFD82E06329DB623C2C@NA-EXMSG-C115.redmond.corp.microsoft.com> Just wanted to send out a ping to the list to let folks know that I'm laying claim to IO for now. We really need to move forward with the libraries implementation, and IO is something that lots of things have dependencies on. If anyone has any objections, please speak up! Thanks, -John -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/ironruby-core/attachments/20071130/a8f2fddb/attachment-0001.html From bacondarwin at googlemail.com Sat Dec 1 09:13:36 2007 From: bacondarwin at googlemail.com (Peter Bacon Darwin) Date: Sat, 1 Dec 2007 14:13:36 -0000 Subject: [Ironruby-core] FW: Can someone do a review of Pete's patch so that we can submit? In-Reply-To: <372109E149E8084D8E6C7D9CFD82E06329DB62357D@NA-EXMSG-C115.redmond.corp.microsoft.com> References: <372109E149E8084D8E6C7D9CFD82E06329DB62357D@NA-EXMSG-C115.redmond.corp.microsoft.com> Message-ID: <000601c83424$5e5fe8f0$1b1fbad0$@com> Sorry if my last mail on this subject sounded a bit defensive. Thanks for reviewing the patch I sent in. I am really pleased that there were no serious issues with the code I wrote for the Bignum class and this gives me confidence to get on with the rest of the numeric classes. Cheers, Pete From: ironruby-core-bounces at rubyforge.org [mailto:ironruby-core-bounces at rubyforge.org] On Behalf Of John Lam (DLR) Sent: Thursday,29 November 29, 2007 22:13 To: ironruby-core at rubyforge.org Subject: [Ironruby-core] FW: Can someone do a review of Pete's patch so that we can submit? Review from Tomas From: Tomas Matousek Sent: Thursday, November 29, 2007 12:32 PM To: John Lam (DLR); IronRuby Team Subject: RE: Can someone do a review of Pete's patch so that we can submit? Few issues: - Fixnum.Abs is incorrect: abs(Int32.MinValue) will blow up, it should overlflow to BigInteger. - Why FloatOps.ToInteger doesn't just do try { return (int)self; } catch (.) {.} ? Flooring is actually incorrect: (-0.4).to_i gives 0 in Ruby while -1 in IronRuby. A test for this is apparently missing. - Why FloatOps.Divmod doesn't use Math.IEEEReminder? There might be some precision peculiarity involved. Tomas -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/ironruby-core/attachments/20071201/29021813/attachment.html From enicholson at gmail.com Sat Dec 1 18:55:11 2007 From: enicholson at gmail.com (Eric Nicholson) Date: Sat, 1 Dec 2007 18:55:11 -0500 Subject: [Ironruby-core] Claiming IO In-Reply-To: <372109E149E8084D8E6C7D9CFD82E06329DB623C2C@NA-EXMSG-C115.redmond.corp.microsoft.com> References: <372109E149E8084D8E6C7D9CFD82E06329DB623C2C@NA-EXMSG-C115.redmond.corp.microsoft.com> Message-ID: That's fine with me. I've done some work on IO (just readLines really), File (most of the static stuff), and the Time class (mostly implemented). But it's on the back burner while I'm working on non-ruby projects :-( and preparing for a baby :-) ! If you want any of the code, I'll be happy to send it your way. Regards, Eric On Dec 1, 2007 12:37 AM, John Lam (DLR) wrote: > Just wanted to send out a ping to the list to let folks know that I'm > laying claim to IO for now. We really need to move forward with the > libraries implementation, and IO is something that lots of things have > dependencies on. > > > > If anyone has any objections, please speak up! > > > > Thanks, > > -John > > > > _______________________________________________ > Ironruby-core mailing list > Ironruby-core at rubyforge.org > http://rubyforge.org/mailman/listinfo/ironruby-core > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/ironruby-core/attachments/20071201/43bd7dcb/attachment.html From lewistm at gmail.com Sun Dec 2 04:24:08 2007 From: lewistm at gmail.com (Terence Lewis) Date: Sun, 2 Dec 2007 11:24:08 +0200 Subject: [Ironruby-core] Implementing socket Message-ID: <2f1decf20712020124x59a42bc7nc6c1cacba42fe009@mail.gmail.com> Hello list, I've been playing around with the IronRuby source for a couple of days trying to figure out how to start an implementation of socket. Unfortunately I've run into some roadblocks, and I'd appreciate any advice you guys can give: 1) Where should my source file(s) live? Initially I created a file Socket.cs in IronRuby.Libraries/BuiltIns, but then I noticed that all the other files in that folder map directly to the "Built-in Classes and Methods" chapter of the pickaxe book, whereas socket sits in the next chapter - "Standard Library". So I had a look in the IronRuby.Libraries/Extensions folder, and decided to move the file in there, but I'm still not 100% sure that's correct. Should there perhaps be a third folder here called "StandardLibrary" or something? 2) How do I get the ruby line "require 'socket'" to work? I tried adding a module called "socket" (a static class Socket with attribute [RubyModule("socket")] and regenerating Initializer.Generated.cs, but when I try and do "require 'socket'" from the interactive console, I get a Ruby.Runtime.LoadError: "Could not load file or assembly 'socket'". This leads me to believe that perhaps socket should be a separate dll, but I think that must be wrong because you'd end up having a different dll for every module in the standard library? 3) Is "module" the correct ruby term for what the socket library is? (I.e is socket a ruby "module"?) Thanks for your time Terence -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/ironruby-core/attachments/20071202/5876380b/attachment.html From jflam at microsoft.com Sun Dec 2 11:18:35 2007 From: jflam at microsoft.com (John Lam (DLR)) Date: Sun, 2 Dec 2007 08:18:35 -0800 Subject: [Ironruby-core] Implementing socket In-Reply-To: <2f1decf20712020124x59a42bc7nc6c1cacba42fe009@mail.gmail.com> References: <2f1decf20712020124x59a42bc7nc6c1cacba42fe009@mail.gmail.com> Message-ID: <372109E149E8084D8E6C7D9CFD82E06329DB623C76@NA-EXMSG-C115.redmond.corp.microsoft.com> Terence Lewis: > I've been playing around with the IronRuby source for a couple of days > trying to figure out how to start an implementation of socket. Excellent! > Unfortunately I've run into some roadblocks, and I'd appreciate any > advice you guys can give: > > 1) Where should my source file(s) live? > 2) How do I get the ruby line "require 'socket'" to work? For the time being, please just make it a Built-In since we don't have require 'zzz' where zzz is a module inside of IronRuby.Libraries working. > 3) Is "module" the correct ruby term for what the socket library is? > (I.e is socket a ruby "module"?) Sure, works for me :) Thanks, -John From haacked at gmail.com Mon Dec 3 14:22:09 2007 From: haacked at gmail.com (Phil Haack) Date: Mon, 03 Dec 2007 11:22:09 -0800 Subject: [Ironruby-core] What replaces RubyEngine.CurrentEngine? Message-ID: <47545761.2060806@gmail.com> Hi All, I'm updating some demos I did for ASP.NET MVC. In particular my "ancient" IronRuby view template (rhtml) demo. You guys have been busy! ;) I wanted to update this wiki entry http://ironruby.rubyforge.org/wiki/wiki.pl?ExecutingIronRubyFromCSharp And I don't know what recplaces the line: RubyEngine re = RubyEngine.CurrentEngine; Could someone point me in the right direction? Thanks! Phil Haack http://haacked.com/ p.s. Could we get a prominent link to this wiki from http://www.ironruby.net/? p.p.s http://ironruby.net/ doesn't point to the same place as www.ironruby.net. Could someone fix the DNS? ;) From curt at hagenlocher.org Mon Dec 3 14:35:37 2007 From: curt at hagenlocher.org (Curt Hagenlocher) Date: Mon, 3 Dec 2007 11:35:37 -0800 Subject: [Ironruby-core] What replaces RubyEngine.CurrentEngine? In-Reply-To: <47545761.2060806@gmail.com> References: <47545761.2060806@gmail.com> Message-ID: On 12/3/07, Phil Haack wrote: > Hi All, I'm updating some demos I did for ASP.NET MVC. Better get cracking; only seven hours until the demo! :P I don't know the correct answer, but if you were using the most recent public update of the source code you could still use RubyEngine.CurrentEngine -- you just have to work around the fact that it's declared "internal". -- Curt Hagenlocher curt at hagenlocher.org From haacked at gmail.com Mon Dec 3 14:46:22 2007 From: haacked at gmail.com (Phil Haack) Date: Mon, 03 Dec 2007 11:46:22 -0800 Subject: [Ironruby-core] What replaces RubyEngine.CurrentEngine? In-Reply-To: References: <47545761.2060806@gmail.com> Message-ID: <47545D0E.3040301@gmail.com> Ha! I'm just preparing it in case I run out of time and need something else whiz-bang to demo. So if I don't get it working, oh well. I'll dance like a monkey for half an hour. I'm using the most recent build. I grabbed from trunk and compiled. Unless someone has a public interface, I'll cheat and use reflection to grab that. ;) Please help! Don't make me cheat. :) Phil Curt Hagenlocher wrote: > On 12/3/07, Phil Haack wrote: > >> Hi All, I'm updating some demos I did for ASP.NET MVC. >> > > Better get cracking; only seven hours until the demo! :P > > I don't know the correct answer, but if you were using the most recent > public update of the source code you could still use > RubyEngine.CurrentEngine -- you just have to work around the fact that > it's declared "internal". > > -- > Curt Hagenlocher > curt at hagenlocher.org > _______________________________________________ > Ironruby-core mailing list > Ironruby-core at rubyforge.org > http://rubyforge.org/mailman/listinfo/ironruby-core > From tomas at winterdom.com Mon Dec 3 15:07:41 2007 From: tomas at winterdom.com (Tomas Restrepo) Date: Mon, 3 Dec 2007 15:07:41 -0500 Subject: [Ironruby-core] What replaces RubyEngine.CurrentEngine? In-Reply-To: <47545D0E.3040301@gmail.com> References: <47545761.2060806@gmail.com> <47545D0E.3040301@gmail.com> Message-ID: Hey Phil, The way I've been doing it has been: ScriptDomainManager manager = ScriptDomainManager.CurrentManager; LanguageProvider ruby = manager.GetLanguageProvider("ruby"); ScriptEngine eng = ruby.GetEngine(); RubyEngine rubyEng = ((RubyEngine)eng); dunno if that will help you. On 12/3/07, Phil Haack wrote: > Ha! I'm just preparing it in case I run out of time and need something > else whiz-bang to demo. So if I don't get it working, oh well. I'll > dance like a monkey for half an hour. > > I'm using the most recent build. I grabbed from trunk and compiled. > Unless someone has a public interface, I'll cheat and use reflection to > grab that. ;) > > Please help! Don't make me cheat. :) > > Phil > > Curt Hagenlocher wrote: > > On 12/3/07, Phil Haack wrote: > > > >> Hi All, I'm updating some demos I did for ASP.NET MVC. > >> > > > > Better get cracking; only seven hours until the demo! :P > > > > I don't know the correct answer, but if you were using the most recent > > public update of the source code you could still use > > RubyEngine.CurrentEngine -- you just have to work around the fact that > > it's declared "internal". > > > > -- > > Curt Hagenlocher > > curt at hagenlocher.org > > _______________________________________________ > > 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 > -- Tomas Restrepo http://www.winterdom.com/weblog/ From haacked at gmail.com Mon Dec 3 16:26:50 2007 From: haacked at gmail.com (Phil Haack) Date: Mon, 03 Dec 2007 13:26:50 -0800 Subject: [Ironruby-core] What replaces RubyEngine.CurrentEngine? In-Reply-To: References: <47545761.2060806@gmail.com> <47545D0E.3040301@gmail.com> Message-ID: <4754749A.2020508@gmail.com> Thanks Tomas! That got me much further. Now I get the following: Could not load file or assembly 'IronRuby, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040) || Line 28: { Line 29: ScriptDomainManager manager = ScriptDomainManager.CurrentManager; Line 30: LanguageProvider ruby = manager.GetLanguageProvider("ruby"); Line 31: ScriptEngine eng = ruby.GetEngine(); Line 32: RubyEngine rubyEng = ((RubyEngine)eng); I assume that's because I compiled IronRuby and it's not strongly signed. Tomas Restrepo wrote: > Hey Phil, > > The way I've been doing it has been: > > ScriptDomainManager manager = ScriptDomainManager.CurrentManager; > LanguageProvider ruby = > manager.GetLanguageProvider("ruby"); > ScriptEngine eng = ruby.GetEngine(); > RubyEngine rubyEng = ((RubyEngine)eng); > > dunno if that will help you. > > On 12/3/07, Phil Haack wrote: > >> Ha! I'm just preparing it in case I run out of time and need something >> else whiz-bang to demo. So if I don't get it working, oh well. I'll >> dance like a monkey for half an hour. >> >> I'm using the most recent build. I grabbed from trunk and compiled. >> Unless someone has a public interface, I'll cheat and use reflection to >> grab that. ;) >> >> Please help! Don't make me cheat. :) >> >> Phil >> >> Curt Hagenlocher wrote: >> >>> On 12/3/07, Phil Haack wrote: >>> >>> >>>> Hi All, I'm updating some demos I did for ASP.NET MVC. >>>> >>>> >>> Better get cracking; only seven hours until the demo! :P >>> >>> I don't know the correct answer, but if you were using the most recent >>> public update of the source code you could still use >>> RubyEngine.CurrentEngine -- you just have to work around the fact that >>> it's declared "internal". >>> >>> -- >>> Curt Hagenlocher >>> curt at hagenlocher.org >>> _______________________________________________ >>> 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 >> >> > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/ironruby-core/attachments/20071203/d5dc8121/attachment.html From bacondarwin at googlemail.com Mon Dec 3 16:33:21 2007 From: bacondarwin at googlemail.com (Peter Bacon Darwin) Date: Mon, 3 Dec 2007 21:33:21 -0000 Subject: [Ironruby-core] Ironing Ruby Message-ID: <001101c835f4$221c1fe0$66545fa0$@com> I have started posting about my experiences with IronRuby at a blog, if you are interested. http://ironingruby.blogspot.com/ I imagine that it may be interesting or helpful to people wanting to get involved in writing library code for IronRuby. Pete -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/ironruby-core/attachments/20071203/ffcd6c64/attachment.html From bacondarwin at googlemail.com Mon Dec 3 16:35:45 2007 From: bacondarwin at googlemail.com (Peter Bacon Darwin) Date: Mon, 3 Dec 2007 21:35:45 -0000 Subject: [Ironruby-core] What replaces RubyEngine.CurrentEngine? In-Reply-To: <4754749A.2020508@gmail.com> References: <47545761.2060806@gmail.com> <47545D0E.3040301@gmail.com> <4754749A.2020508@gmail.com> Message-ID: <001601c835f4$77d1ce30$67756a90$@com> I believe there is a conditional compilation symbols called SIGNED. If you remove that from all the projects, then the language loading mechanism doesn't try to use the public key. I think! Pete From: ironruby-core-bounces at rubyforge.org [mailto:ironruby-core-bounces at rubyforge.org] On Behalf Of Phil Haack Sent: Monday,03 December 03, 2007 21:27 To: ironruby-core at rubyforge.org Subject: Re: [Ironruby-core] What replaces RubyEngine.CurrentEngine? Thanks Tomas! That got me much further. Now I get the following: Could not load file or assembly 'IronRuby, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040) Line 28: { Line 29: ScriptDomainManager manager = ScriptDomainManager.CurrentManager; Line 30: LanguageProvider ruby = manager.GetLanguageProvider("ruby"); Line 31: ScriptEngine eng = ruby.GetEngine(); Line 32: RubyEngine rubyEng = ((RubyEngine)eng); I assume that's because I compiled IronRuby and it's not strongly signed. Tomas Restrepo wrote: Hey Phil, The way I've been doing it has been: ScriptDomainManager manager = ScriptDomainManager.CurrentManager; LanguageProvider ruby = manager.GetLanguageProvider("ruby"); ScriptEngine eng = ruby.GetEngine(); RubyEngine rubyEng = ((RubyEngine)eng); dunno if that will help you. On 12/3/07, Phil Haack wrote: Ha! I'm just preparing it in case I run out of time and need something else whiz-bang to demo. So if I don't get it working, oh well. I'll dance like a monkey for half an hour. I'm using the most recent build. I grabbed from trunk and compiled. Unless someone has a public interface, I'll cheat and use reflection to grab that. ;) Please help! Don't make me cheat. :) Phil Curt Hagenlocher wrote: On 12/3/07, Phil Haack wrote: Hi All, I'm updating some demos I did for ASP.NET MVC. Better get cracking; only seven hours until the demo! :P I don't know the correct answer, but if you were using the most recent public update of the source code you could still use RubyEngine.CurrentEngine -- you just have to work around the fact that it's declared "internal". -- Curt Hagenlocher curt at hagenlocher.org _______________________________________________ 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 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/ironruby-core/attachments/20071203/d986391c/attachment-0001.html From tomas at winterdom.com Mon Dec 3 16:41:55 2007 From: tomas at winterdom.com (Tomas Restrepo) Date: Mon, 3 Dec 2007 16:41:55 -0500 Subject: [Ironruby-core] What replaces RubyEngine.CurrentEngine? In-Reply-To: <001601c835f4$77d1ce30$67756a90$@com> References: <47545761.2060806@gmail.com> <47545D0E.3040301@gmail.com> <4754749A.2020508@gmail.com> <001601c835f4$77d1ce30$67756a90$@com> Message-ID: Yep, I think Peter's right. The relevant piece of code seems to be in Hosting\ScriptEnvironmentSetup.cs, line 139 in the DLR assembly. On 12/3/07, Peter Bacon Darwin wrote: > > I believe there is a conditional compilation symbols called SIGNED. If > you remove that from all the projects, then the language loading mechanism > doesn't try to use the public key. I think! > > Pete > > > > *From:* ironruby-core-bounces at rubyforge.org [mailto: > ironruby-core-bounces at rubyforge.org] *On Behalf Of *Phil Haack > *Sent:* Monday,03 December 03, 2007 21:27 > *To:* ironruby-core at rubyforge.org > *Subject:* Re: [Ironruby-core] What replaces RubyEngine.CurrentEngine? > > > > Thanks Tomas! That got me much further. Now I get the following: > > Could not load file or assembly 'IronRuby, Version=1.0.0.0, > Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its > dependencies. The located assembly's manifest definition does not match the > assembly reference. (Exception from HRESULT: 0x80131040) > > Line 28: { > > Line 29: ScriptDomainManager manager = ScriptDomainManager.CurrentManager; > > Line 30: LanguageProvider ruby = manager.GetLanguageProvider("ruby"); > > Line 31: ScriptEngine eng = ruby.GetEngine(); > > Line 32: RubyEngine rubyEng = ((RubyEngine)eng); > > > I assume that's because I compiled IronRuby and it's not strongly signed. > > > Tomas Restrepo wrote: > > Hey Phil, > > > > The way I've been doing it has been: > > > > ScriptDomainManager manager = ScriptDomainManager.CurrentManager; > > LanguageProvider ruby = > > manager.GetLanguageProvider("ruby"); > > ScriptEngine eng = ruby.GetEngine(); > > RubyEngine rubyEng = ((RubyEngine)eng); > > > > dunno if that will help you. > > > > On 12/3/07, Phil Haack wrote: > > > > Ha! I'm just preparing it in case I run out of time and need something > > else whiz-bang to demo. So if I don't get it working, oh well. I'll > > dance like a monkey for half an hour. > > > > I'm using the most recent build. I grabbed from trunk and compiled. > > Unless someone has a public interface, I'll cheat and use reflection to > > grab that. ;) > > > > Please help! Don't make me cheat. :) > > > > Phil > > > > Curt Hagenlocher wrote: > > > > On 12/3/07, Phil Haack wrote: > > > > > > Hi All, I'm updating some demos I did for ASP.NET MVC. > > > > > > Better get cracking; only seven hours until the demo! :P > > > > I don't know the correct answer, but if you were using the most recent > > public update of the source code you could still use > > RubyEngine.CurrentEngine -- you just have to work around the fact that > > it's declared "internal". > > > > -- > > Curt Hagenlocher > > curt at hagenlocher.org > > _______________________________________________ > > 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 > > > > > > > > > > > > > > _______________________________________________ > Ironruby-core mailing list > Ironruby-core at rubyforge.org > http://rubyforge.org/mailman/listinfo/ironruby-core > > -- Tomas Restrepo http://www.winterdom.com/weblog/ -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/ironruby-core/attachments/20071203/923e45ad/attachment.html From tomas at winterdom.com Mon Dec 3 16:46:12 2007 From: tomas at winterdom.com (Tomas Restrepo) Date: Mon, 3 Dec 2007 16:46:12 -0500 Subject: [Ironruby-core] Build issues? Message-ID: Am I the only one having issues building the current IronRuby/DLR code? Some of the issues I've noticed: 1- "rake compile" seems to brake for me always, because it deletes the output directory first but doesn't recreate it, and then the compilation for the resources in Microsoft.Scripting.dll breaks because of it. 2- Manually creating the output directory and then doing "rake compile_dlr" followed by "rake compile_ruby" works around the issue. But, that brings me to another point: There doesn't seem to be a rake option to build IronRuby.Libraries! 3- Building using msbuild.... not working so well, either, as some of the projects still seem to have project references that use the old directory names... -- Tomas Restrepo http://www.winterdom.com/weblog/ From haacked at gmail.com Mon Dec 3 16:48:28 2007 From: haacked at gmail.com (Phil Haack) Date: Mon, 03 Dec 2007 13:48:28 -0800 Subject: [Ironruby-core] What replaces RubyEngine.CurrentEngine? In-Reply-To: References: <47545761.2060806@gmail.com> <47545D0E.3040301@gmail.com> <4754749A.2020508@gmail.com> <001601c835f4$77d1ce30$67756a90$@com> Message-ID: <475479AC.8010504@gmail.com> Odd, I tried that and still had problems. This is what fixed it for me: LanguageProvider ruby = manager.GetLanguageProvider(typeof(RubyLanguageProvider)); I just explicitly passed in the type. All's good now. Thanks for the help! Tomas Restrepo wrote: > Yep, I think Peter's right. The relevant piece of code seems to be in > Hosting\ScriptEnvironmentSetup.cs, line 139 in the DLR assembly. > > On 12/3/07, *Peter Bacon Darwin * > wrote: > > I believe there is a conditional compilation symbols called > SIGNED. If you remove that from all the projects, then the > language loading mechanism doesn't try to use the public key. I > think! > > Pete > > > > *From:* ironruby-core-bounces at rubyforge.org > > [mailto:ironruby-core-bounces at rubyforge.org > ] *On Behalf Of *Phil > Haack > *Sent:* Monday,03 December 03, 2007 21:27 > *To:* ironruby-core at rubyforge.org > *Subject:* Re: [Ironruby-core] What replaces RubyEngine.CurrentEngine? > > > > Thanks Tomas! That got me much further. Now I get the following: > > Could not load file or assembly 'IronRuby, Version=1.0.0.0 > , Culture=neutral, > PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The > located assembly's manifest definition does not match the assembly > reference. (Exception from HRESULT: 0x80131040) > > Line 28: { > > Line 29: ScriptDomainManager manager = ScriptDomainManager.CurrentManager; > > Line 30: LanguageProvider ruby = > manager.GetLanguageProvider("ruby"); > > Line 31: ScriptEngine eng = ruby.GetEngine(); > > Line 32: RubyEngine rubyEng = ((RubyEngine)eng); > > > I assume that's because I compiled IronRuby and it's not strongly > signed. > > > Tomas Restrepo wrote: > > Hey Phil, > > > > The way I've been doing it has been: > > > > ScriptDomainManager manager = ScriptDomainManager.CurrentManager; > > LanguageProvider ruby = > > manager.GetLanguageProvider > ("ruby"); > > ScriptEngine eng = ruby.GetEngine(); > > RubyEngine rubyEng = ((RubyEngine)eng); > > > > dunno if that will help you. > > > > On 12/3/07, Phil Haack > wrote: > > > > Ha! I'm just preparing it in case I run out of time and need something > > else whiz-bang to demo. So if I don't get it working, oh well. I'll > > > dance like a monkey for half an hour. > > > > I'm using the most recent build. I grabbed from trunk and compiled. > > Unless someone has a public interface, I'll cheat and use reflection to > > > grab that. ;) > > > > Please help! Don't make me cheat. :) > > > > Phil > > > > Curt Hagenlocher wrote: > > > > On 12/3/07, Phil Haack > wrote: > > > > > > Hi All, I'm updating some demos I did for ASP.NET MVC. > > > > > > > Better get cracking; only seven hours until the demo! :P > > > > I don't know the correct answer, but if you were using the most recent > > public update of the source code you could still use > > > RubyEngine.CurrentEngine -- you just have to work around the fact that > > it's declared "internal". > > > > -- > > Curt Hagenlocher > > > curt at hagenlocher.org > > _______________________________________________ > > 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 > > > > > > > > > > > > > > > _______________________________________________ > Ironruby-core mailing list > Ironruby-core at rubyforge.org > http://rubyforge.org/mailman/listinfo/ironruby-core > > > > > -- > Tomas Restrepo > http://www.winterdom.com/weblog/ > ------------------------------------------------------------------------ > > _______________________________________________ > Ironruby-core mailing list > Ironruby-core at rubyforge.org > http://rubyforge.org/mailman/listinfo/ironruby-core > From jflam at microsoft.com Mon Dec 3 16:51:22 2007 From: jflam at microsoft.com (John Lam (DLR)) Date: Mon, 3 Dec 2007 13:51:22 -0800 Subject: [Ironruby-core] Build issues? In-Reply-To: References: Message-ID: <372109E149E8084D8E6C7D9CFD82E06329DB72F6A4@NA-EXMSG-C115.redmond.corp.microsoft.com> Tomas Restrepo: > Am I the only one having issues building the current IronRuby/DLR code? > > Some of the issues I've noticed: > > 1- "rake compile" seems to brake for me always, because it deletes the > output directory first but doesn't recreate it, and then the > compilation for the resources in Microsoft.Scripting.dll breaks > because of it. > > 2- Manually creating the output directory and then doing "rake > compile_dlr" followed by "rake compile_ruby" works around the issue. > But, that brings me to another point: There doesn't seem to be a rake > option to build IronRuby.Libraries! Umm ... rake compile_libraries? Smells like you have an older version of the Rakefile there? > > 3- Building using msbuild.... not working so well, either, as some of > the projects still seem to have project references that use the old > directory names... You'll need to use the IronRuby.sln solution and not Ruby.sln. This runs fine here: msbuild /p:Configuration="Debug" IronRuby.sln -John From haacked at gmail.com Mon Dec 3 16:52:24 2007 From: haacked at gmail.com (Phil Haack) Date: Mon, 03 Dec 2007 13:52:24 -0800 Subject: [Ironruby-core] Build issues? In-Reply-To: References: Message-ID: <47547A98.4030701@gmail.com> I was able to build by setting the solution configuration to ExternalDebug and then building. As for rake, I needed to do this first: gem install pathname2 Then when I did rake compile, I got some runtime error in rake. :( Building from VS seemed to work for me. Phil Tomas Restrepo wrote: > Am I the only one having issues building the current IronRuby/DLR code? > > Some of the issues I've noticed: > > 1- "rake compile" seems to brake for me always, because it deletes the > output directory first but doesn't recreate it, and then the > compilation for the resources in Microsoft.Scripting.dll breaks > because of it. > > 2- Manually creating the output directory and then doing "rake > compile_dlr" followed by "rake compile_ruby" works around the issue. > But, that brings me to another point: There doesn't seem to be a rake > option to build IronRuby.Libraries! > > 3- Building using msbuild.... not working so well, either, as some of > the projects still seem to have project references that use the old > directory names... > > From jflam at microsoft.com Mon Dec 3 16:52:45 2007 From: jflam at microsoft.com (John Lam (DLR)) Date: Mon, 3 Dec 2007 13:52:45 -0800 Subject: [Ironruby-core] What replaces RubyEngine.CurrentEngine? In-Reply-To: References: <47545761.2060806@gmail.com> <47545D0E.3040301@gmail.com> <4754749A.2020508@gmail.com> <001601c835f4$77d1ce30$67756a90$@com> Message-ID: <372109E149E8084D8E6C7D9CFD82E06329DB72F6A7@NA-EXMSG-C115.redmond.corp.microsoft.com> Tomas Restrepo: > Yep, I think Peter's right. The relevant piece of code seems to be in > Hosting\ScriptEnvironmentSetup.cs, line 139 in the DLR assembly. Yes - this is a problem with SIGNED leaking into the project files. I need to modify the Rakefile to scrub SIGNED from the generated .csproj files that y'all use. For the time being, just remove SIGNED from the .csproj files and you should be good to go. -John From tomas at winterdom.com Mon Dec 3 16:57:10 2007 From: tomas at winterdom.com (Tomas Restrepo) Date: Mon, 3 Dec 2007 16:57:10 -0500 Subject: [Ironruby-core] Build issues? In-Reply-To: <372109E149E8084D8E6C7D9CFD82E06329DB72F6A4@NA-EXMSG-C115.redmond.corp.microsoft.com> References: <372109E149E8084D8E6C7D9CFD82E06329DB72F6A4@NA-EXMSG-C115.redmond.corp.microsoft.com> Message-ID: Hi John! > Umm ... rake compile_libraries? Ahh, thanks, that works. Then the problem is that it is not listed in the help when you just hit rake alongside the other options. > You'll need to use the IronRuby.sln solution and not Ruby.sln. This runs fine here: > > msbuild /p:Configuration="Debug" IronRuby.sln Nope, doesn't work here. It breaks when compiling Ruby.csproj with a bunch of missing references errors. (the DLR builds fine, but the IronRuby project can't find it, and same for the libraries project). I did do yet another svn update just in case. -- Tomas Restrepo http://www.winterdom.com/weblog/ From jflam at microsoft.com Mon Dec 3 17:51:20 2007 From: jflam at microsoft.com (John Lam (DLR)) Date: Mon, 3 Dec 2007 14:51:20 -0800 Subject: [Ironruby-core] Build issues? In-Reply-To: References: <372109E149E8084D8E6C7D9CFD82E06329DB72F6A4@NA-EXMSG-C115.redmond.corp.microsoft.com> Message-ID: <372109E149E8084D8E6C7D9CFD82E06329DB72F727@NA-EXMSG-C115.redmond.corp.microsoft.com> Tomas Restrepo: > > You'll need to use the IronRuby.sln solution and not Ruby.sln. This > runs fine here: > > > > msbuild /p:Configuration="Debug" IronRuby.sln > > Nope, doesn't work here. It breaks when compiling Ruby.csproj with a > bunch of missing references errors. (the DLR builds fine, but the > IronRuby project can't find it, and same for the libraries project). I just deleted my svn directory and re-synced with r65. MSBuild it blew up the first time I ran it, but then it compiled fine the second time around. It looks like something might be screwed up with build ordering. Does rake compile still fail out of the box with r65? If you can mail a text dump of the build output that will be helpful in diagnosing what might be busted. Thanks, -John From tomas at winterdom.com Mon Dec 3 18:12:54 2007 From: tomas at winterdom.com (Tomas Restrepo) Date: Mon, 3 Dec 2007 18:12:54 -0500 Subject: [Ironruby-core] Build issues? In-Reply-To: <372109E149E8084D8E6C7D9CFD82E06329DB72F727@NA-EXMSG-C115.redmond.corp.microsoft.com> References: <372109E149E8084D8E6C7D9CFD82E06329DB72F6A4@NA-EXMSG-C115.redmond.corp.microsoft.com> <372109E149E8084D8E6C7D9CFD82E06329DB72F727@NA-EXMSG-C115.redmond.corp.microsoft.com> Message-ID: Hey John, > > Does rake compile still fail out of the box with r65? Weird, tried it again and seems to be working now (though svn didn't update anything this time). As for the msbuild file, running it multiple times doesn't seem to do the trick. It goes something like this: __________________________________________________ Project "E:\Opensource\ironruby\trunk\IronRuby.sln" is building "E:\Opensource\ironruby\trunk\src\ironruby\Ruby.csproj" (default targets): Target ResolveProjectReferences: C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Microsoft.Common.targets : warning : The referenced project '..\..\..\Runtime\Microsoft.Scripting\Microsoft.Scripting.csproj' does not exist. Done building target "ResolveProjectReferences" in project "Ruby.csproj". Target CoreCompile: Compiler\AST\Expressions\ConditionalJumpExpression.cs(20,17): error CS0234: The type or namespace name 'Scripting' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?) Compiler\AST\Expressions\ConditionalJumpExpression.cs(22,17): error CS0234: The type or namespace name 'Scripting' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?) and a lot more after that. -- Tomas Restrepo http://www.winterdom.com/weblog/ From jflam at microsoft.com Mon Dec 3 18:17:18 2007 From: jflam at microsoft.com (John Lam (DLR)) Date: Mon, 3 Dec 2007 15:17:18 -0800 Subject: [Ironruby-core] Build issues? In-Reply-To: References: <372109E149E8084D8E6C7D9CFD82E06329DB72F6A4@NA-EXMSG-C115.redmond.corp.microsoft.com> <372109E149E8084D8E6C7D9CFD82E06329DB72F727@NA-EXMSG-C115.redmond.corp.microsoft.com> Message-ID: <372109E149E8084D8E6C7D9CFD82E06329DB72F75B@NA-EXMSG-C115.redmond.corp.microsoft.com> > Project "E:\Opensource\ironruby\trunk\IronRuby.sln" is > building "E:\Opensource\ironruby\trunk\src\ironruby\Ruby.csproj" > (default targets): > > Target ResolveProjectReferences: > > C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Microsoft.Common.targets > : warning : The referenced project > '..\..\..\Runtime\Microsoft.Scripting\Microsoft.Scripting.csproj' does > not exist. > Done building target "ResolveProjectReferences" in project > "Ruby.csproj". > Target CoreCompile: > > > Compiler\AST\Expressions\ConditionalJumpExpression.cs(20,17): > error CS0234: The type or namespace name 'Scripting' does not exist in > the namespace 'Microsoft' (are you missing an assembly reference?) > > Compiler\AST\Expressions\ConditionalJumpExpression.cs(22,17): > error CS0234: The type or namespace name 'Scripting' does not exist in > the namespace 'Microsoft' (are you missing an assembly reference?) > > and a lot more after that. Can you send me a copy of your ruby.csproj (off list is fine). It seems like you've got a borked copy of ruby.csproj, but I want to confirm this. Also, have you tried to dump the svn repository into some other fresh directory on your machine and building there? Thanks, -John From jflam at microsoft.com Mon Dec 3 18:36:20 2007 From: jflam at microsoft.com (John Lam (DLR)) Date: Mon, 3 Dec 2007 15:36:20 -0800 Subject: [Ironruby-core] Ironing Ruby In-Reply-To: <001101c835f4$221c1fe0$66545fa0$@com> References: <001101c835f4$221c1fe0$66545fa0$@com> Message-ID: <372109E149E8084D8E6C7D9CFD82E06329DB72F777@NA-EXMSG-C115.redmond.corp.microsoft.com> Peter Bacon Darwin: > I have started posting about my experiences with IronRuby at a blog, > if you are interested. > > http://ironingruby.blogspot.com/ > > I imagine that it may be interesting or helpful to people wanting to > get involved in writing library code for IronRuby. Great first post! I like the way you tell the story - starting with wondering how it would change if you tried something new followed by an investigation of how it does what you were trying. -John PS an awesome name! From tomas at winterdom.com Mon Dec 3 19:35:43 2007 From: tomas at winterdom.com (Tomas Restrepo) Date: Mon, 3 Dec 2007 19:35:43 -0500 Subject: [Ironruby-core] Build issues? In-Reply-To: <372109E149E8084D8E6C7D9CFD82E06329DB72F75B@NA-EXMSG-C115.redmond.corp.microsoft.com> References: <372109E149E8084D8E6C7D9CFD82E06329DB72F6A4@NA-EXMSG-C115.redmond.corp.microsoft.com> <372109E149E8084D8E6C7D9CFD82E06329DB72F727@NA-EXMSG-C115.redmond.corp.microsoft.com> <372109E149E8084D8E6C7D9CFD82E06329DB72F75B@NA-EXMSG-C115.redmond.corp.microsoft.com> Message-ID: > Can you send me a copy of your ruby.csproj (off list is fine). It seems like you've got a borked copy of ruby.csproj, but I want to confirm this. Done. Thanks. > > Also, have you tried to dump the svn repository into some other fresh directory on your machine and building there? Yep. Just deleted the whole tree and got it fresh from SVN and got the exact same error. -- Tomas Restrepo http://www.winterdom.com/weblog/ From jflam at microsoft.com Mon Dec 3 23:32:46 2007 From: jflam at microsoft.com (John Lam (DLR)) Date: Mon, 3 Dec 2007 20:32:46 -0800 Subject: [Ironruby-core] Build issues? In-Reply-To: References: <372109E149E8084D8E6C7D9CFD82E06329DB72F6A4@NA-EXMSG-C115.redmond.corp.microsoft.com> <372109E149E8084D8E6C7D9CFD82E06329DB72F727@NA-EXMSG-C115.redmond.corp.microsoft.com> <372109E149E8084D8E6C7D9CFD82E06329DB72F75B@NA-EXMSG-C115.redmond.corp.microsoft.com> Message-ID: <372109E149E8084D8E6C7D9CFD82E06329DB72F8A4@NA-EXMSG-C115.redmond.corp.microsoft.com> Tomas Restrepo: > > Can you send me a copy of your ruby.csproj (off list is fine). It > seems like you've got a borked copy of ruby.csproj, but I want to > confirm this. > > Done. Thanks. > > > > Also, have you tried to dump the svn repository into some other fresh > directory on your machine and building there? > > Yep. Just deleted the whole tree and got it fresh from SVN and got the > exact same error. > Wow ... this is spooky. My local version is different from what's in SVN right now (via the HTTP browser [1]), but I just did a clean pull from SVN. It looks like something is messed up in a cache somewhere. Let's see what I can do to fix this. Thanks, -John [1] http://ironruby.rubyforge.org/svn/trunk/src/ironruby/Ruby.csproj From jflam at microsoft.com Tue Dec 4 19:25:45 2007 From: jflam at microsoft.com (John Lam (DLR)) Date: Tue, 4 Dec 2007 16:25:45 -0800 Subject: [Ironruby-core] Claiming IO In-Reply-To: References: <372109E149E8084D8E6C7D9CFD82E06329DB623C2C@NA-EXMSG-C115.redmond.corp.microsoft.com> Message-ID: <372109E149E8084D8E6C7D9CFD82E06329DB72FE31@NA-EXMSG-C115.redmond.corp.microsoft.com> Eric Nicholson: > Sent: Saturday, December 01, 2007 3:55 PM > To: ironruby-core at rubyforge.org > Subject: Re: [Ironruby-core] Claiming IO > > That's fine with me. I've done some work on IO (just readLines > really), File (most of the static stuff), and the Time class (mostly > implemented). But it's on the back burner while I'm working on non- > ruby projects :-( and preparing for a baby :-) ! > > If you want any of the code, I'll be happy to send it your way. Please do send it along. I'd love to merge them into my patch. Thanks, -John PS Don't think that anything that you do now will prepare for the baby ... :) From eduardo at fusionmxsoftware.com Tue Dec 4 19:27:29 2007 From: eduardo at fusionmxsoftware.com (Eduardo A. Flores Verduzco) Date: Tue, 4 Dec 2007 18:27:29 -0600 Subject: [Ironruby-core] Claiming IO In-Reply-To: <372109E149E8084D8E6C7D9CFD82E06329DB72FE31@NA-EXMSG-C115.redmond.corp.microsoft.com> References: <372109E149E8084D8E6C7D9CFD82E06329DB623C2C@NA-EXMSG-C115.redmond.corp.microsoft.com> <372109E149E8084D8E6C7D9CFD82E06329DB72FE31@NA-EXMSG-C115.redmond.corp.microsoft.com> Message-ID: <57ad48f30712041627n6f59412dxb67a7371f444e190@mail.gmail.com> TOTALLY agree with the PS. Congrats, Eric On Dec 4, 2007 6:25 PM, John Lam (DLR) wrote: > Eric Nicholson: > > > Sent: Saturday, December 01, 2007 3:55 PM > > To: ironruby-core at rubyforge.org > > Subject: Re: [Ironruby-core] Claiming IO > > > > That's fine with me. I've done some work on IO (just readLines > > really), File (most of the static stuff), and the Time class (mostly > > implemented). But it's on the back burner while I'm working on non- > > ruby projects :-( and preparing for a baby :-) ! > > > > If you want any of the code, I'll be happy to send it your way. > > Please do send it along. I'd love to merge them into my patch. > > Thanks, > -John > > PS Don't think that anything that you do now will prepare for the baby ... > :) > > _______________________________________________ > Ironruby-core mailing list > Ironruby-core at rubyforge.org > http://rubyforge.org/mailman/listinfo/ironruby-core > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/ironruby-core/attachments/20071204/bd7c399d/attachment.html From bacondarwin at googlemail.com Thu Dec 6 05:39:50 2007 From: bacondarwin at googlemail.com (Peter Bacon Darwin) Date: Thu, 6 Dec 2007 10:39:50 -0000 Subject: [Ironruby-core] Raising Exceptions Message-ID: <000301c837f4$55b9b180$012d1480$@com> Just a quick question about raising exceptions in IronRuby libraries. Should we just simply throw a new CLR exception or do we need to use the ExceptionOps stuff when creating exceptions. As an example, in FloatOps, I have a method for divmod: [RubyMethod("divmod")] public static RubyArray DivMod(double self, double other) { // Unlike modulo, divmod throws an error if the quotient is not a proper number. // This appears to be an inconsistency in MRI. double quotient = self / other; if (Double.IsNaN(quotient) || Double.IsInfinity(quotient) ) { throw new FloatDomainError("NaN"); } return InternalDivMod(self, other); } If the quotient is not valid then we raise a FloatDomainError. The FloatDomainError class uses ExceptionOps.MakeMessage and also ExceptionOps.InitializeException in the constructor. A quick look at InitializeException puts some data into the Exception.Data property, which I am assuming, without going any deeper, is required by the Ruby runtime to handle the exception correctly. This is all well and good, but when you look at BignumOps, I have a method for to_s: [RubyMethod("to_s")] public static object ToString(BigInteger self, uint radix) { try { // TODO: Can we do the ToLower in BigInteger? return new MutableString(self.ToString(radix).ToLower()); } catch (ArgumentOutOfRangeException x) { throw ArgumentErrorOps.Factory(new MutableString(x.Message)); } } Now this one needs to raise an ArgumentError, which is actually a Ruby wrapper around System.ArgumentException (i.e. ArgumentError is a pure Ruby class that "extends" the CLR class System.ArgumentException. Now I could have just created a new ArgumentException here but since this doesn't call, apart from anything else, ExceptionOps.InitializeException, I felt I needed to use the ArgumentErrorOps.Factory method to create the exception. I believe the primary reason for this method is so that the DLR can create exceptions from pure Ruby code, i.e. raise ArgumentError, ... Am I being over-cautious here and should I be happily creating CLR exceptions directly and not worrying too much? I expect and hope that this is the case, as otherwise how would the DLR deal with cases where pure .NET classes throw pure CLR exceptions? Cheers, Pete -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/ironruby-core/attachments/20071206/cad6ece3/attachment-0001.html From bacondarwin at googlemail.com Thu Dec 6 08:53:48 2007 From: bacondarwin at googlemail.com (Peter Bacon Darwin) Date: Thu, 6 Dec 2007 13:53:48 -0000 Subject: [Ironruby-core] Raising Exceptions Message-ID: <000001c8380f$6dead2f0$49c078d0$@com> And to add further confusion there are also RubyExceptions.CreateXXXError methods available. What to use? Pete -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/ironruby-core/attachments/20071206/32c622bf/attachment.html From jflam at microsoft.com Thu Dec 6 12:27:38 2007 From: jflam at microsoft.com (John Lam (DLR)) Date: Thu, 6 Dec 2007 09:27:38 -0800 Subject: [Ironruby-core] Raising Exceptions In-Reply-To: <000301c837f4$55b9b180$012d1480$@com> References: <000301c837f4$55b9b180$012d1480$@com> Message-ID: <372109E149E8084D8E6C7D9CFD82E06329DB7D8AAF@NA-EXMSG-C115.redmond.corp.microsoft.com> Our automatic exception mapping mechanism maps ArgumentOutOfRangeExceptions to RangeErrors. Since the correct behavior in this case appears to be raising an ArgumentError, it makes sense to catch and rethrow. I'm attaching a PDF that shows how we map CLR exceptions to Ruby exceptions. Thanks, -John From: ironruby-core-bounces at rubyforge.org [mailto:ironruby-core-bounces at rubyforge.org] On Behalf Of Peter Bacon Darwin Sent: Thursday, December 06, 2007 2:40 AM To: ironruby-core at rubyforge.org Subject: [Ironruby-core] Raising Exceptions Just a quick question about raising exceptions in IronRuby libraries. Should we just simply throw a new CLR exception or do we need to use the ExceptionOps stuff when creating exceptions. As an example, in FloatOps, I have a method for divmod: [RubyMethod("divmod")] public static RubyArray DivMod(double self, double other) { // Unlike modulo, divmod throws an error if the quotient is not a proper number. // This appears to be an inconsistency in MRI. double quotient = self / other; if (Double.IsNaN(quotient) || Double.IsInfinity(quotient) ) { throw new FloatDomainError("NaN"); } return InternalDivMod(self, other); } If the quotient is not valid then we raise a FloatDomainError. The FloatDomainError class uses ExceptionOps.MakeMessage and also ExceptionOps.InitializeException in the constructor. A quick look at InitializeException puts some data into the Exception.Data property, which I am assuming, without going any deeper, is required by the Ruby runtime to handle the exception correctly. This is all well and good, but when you look at BignumOps, I have a method for to_s: [RubyMethod("to_s")] public static object ToString(BigInteger self, uint radix) { try { // TODO: Can we do the ToLower in BigInteger? return new MutableString(self.ToString(radix).ToLower()); } catch (ArgumentOutOfRangeException x) { throw ArgumentErrorOps.Factory(new MutableString(x.Message)); } } Now this one needs to raise an ArgumentError, which is actually a Ruby wrapper around System.ArgumentException (i.e. ArgumentError is a pure Ruby class that "extends" the CLR class System.ArgumentException. Now I could have just created a new ArgumentException here but since this doesn't call, apart from anything else, ExceptionOps.InitializeException, I felt I needed to use the ArgumentErrorOps.Factory method to create the exception. I believe the primary reason for this method is so that the DLR can create exceptions from pure Ruby code, i.e. raise ArgumentError, ... Am I being over-cautious here and should I be happily creating CLR exceptions directly and not worrying too much? I expect and hope that this is the case, as otherwise how would the DLR deal with cases where pure .NET classes throw pure CLR exceptions? Cheers, Pete -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/ironruby-core/attachments/20071206/5784c170/attachment-0001.html -------------- next part -------------- A non-text attachment was scrubbed... Name: ExceptionHierarchy.pdf Type: application/pdf Size: 10274 bytes Desc: ExceptionHierarchy.pdf Url : http://rubyforge.org/pipermail/ironruby-core/attachments/20071206/5784c170/attachment-0001.pdf From jomes at microsoft.com Thu Dec 6 14:05:52 2007 From: jomes at microsoft.com (John Messerly) Date: Thu, 6 Dec 2007 11:05:52 -0800 Subject: [Ironruby-core] Raising Exceptions In-Reply-To: <372109E149E8084D8E6C7D9CFD82E06329DB7D8AAF@NA-EXMSG-C115.redmond.corp.microsoft.com> References: <000301c837f4$55b9b180$012d1480$@com> <372109E149E8084D8E6C7D9CFD82E06329DB7D8AAF@NA-EXMSG-C115.redmond.corp.microsoft.com> Message-ID: <918705E903F4714CB713D89AB5F1857D738E9E21A2@NA-EXMSG-C116.redmond.corp.microsoft.com> John Lam (DLR): > I'm attaching a PDF that shows how we map CLR exceptions to Ruby > exceptions. I guess the ! means "not equivalent" and "skip parent" means we change the base class mapping but otherwise map it? (Also the bottom of the PDF appears cut off.) - John From jomes at microsoft.com Thu Dec 6 14:07:12 2007 From: jomes at microsoft.com (John Messerly) Date: Thu, 6 Dec 2007 11:07:12 -0800 Subject: [Ironruby-core] Raising Exceptions In-Reply-To: <000001c8380f$6dead2f0$49c078d0$@com> References: <000001c8380f$6dead2f0$49c078d0$@com> Message-ID: <918705E903F4714CB713D89AB5F1857D738E9E21A7@NA-EXMSG-C116.redmond.corp.microsoft.com> Peter Bacon Darwin: > And to add further confusion there are also > RubyExceptions.CreateXXXError methods available. > > What to use? I think the convention is to use the RubyExceptions.CreateXXXError methods (although I'm not clear on the reason). - John From jflam at microsoft.com Thu Dec 6 14:25:04 2007 From: jflam at microsoft.com (John Lam (DLR)) Date: Thu, 6 Dec 2007 11:25:04 -0800 Subject: [Ironruby-core] Raising Exceptions In-Reply-To: <918705E903F4714CB713D89AB5F1857D738E9E21A7@NA-EXMSG-C116.redmond.corp.microsoft.com> References: <000001c8380f$6dead2f0$49c078d0$@com> <918705E903F4714CB713D89AB5F1857D738E9E21A7@NA-EXMSG-C116.redmond.corp.microsoft.com> Message-ID: <372109E149E8084D8E6C7D9CFD82E06329DB7D8BA9@NA-EXMSG-C115.redmond.corp.microsoft.com> John Messerly: > Peter Bacon Darwin: > > > And to add further confusion there are also > > RubyExceptions.CreateXXXError methods available. > > > > What to use? > > I think the convention is to use the RubyExceptions.CreateXXXError > methods (although I'm not clear on the reason). > It's so that you can think in terms of Ruby errors and not what the .NET exception type should be (IOW you don't need to read the diagram each time). -John From Tomas.Matousek at microsoft.com Thu Dec 6 14:31:04 2007 From: Tomas.Matousek at microsoft.com (Tomas Matousek) Date: Thu, 6 Dec 2007 11:31:04 -0800 Subject: [Ironruby-core] Raising Exceptions In-Reply-To: <918705E903F4714CB713D89AB5F1857D738E9E21A7@NA-EXMSG-C116.redmond.corp.microsoft.com> References: <000001c8380f$6dead2f0$49c078d0$@com> <918705E903F4714CB713D89AB5F1857D738E9E21A7@NA-EXMSG-C116.redmond.corp.microsoft.com> Message-ID: Yes, use RubyExceptions where possible. Otherwise just throw corresponding BCL exception. We may enrich RubyException class with more commonly thrown exceptions. When we do so, we will search and replace affected throws across the library - that's easy. So if you don't find the exception that should be thrown in this class feel free to just throw the BCL exception directly. The reasons for using RubyExceptions are clarity, code reuse and consistency in error messages. RubyExceptions class should be one of the few places where Ruby to BCL exception mapping takes place - methods on RubyExceptions should be named after Ruby exception classes, so the library writer doesn't need to think about the mapping. The class needs some refactoring though and it should probably be moved to the library. It's on my TODO list to do so. Tomas -----Original Message----- From: ironruby-core-bounces at rubyforge.org [mailto:ironruby-core-bounces at rubyforge.org] On Behalf Of John Messerly Sent: Thursday, December 06, 2007 11:07 AM To: ironruby-core at rubyforge.org Subject: Re: [Ironruby-core] Raising Exceptions Peter Bacon Darwin: > And to add further confusion there are also > RubyExceptions.CreateXXXError methods available. > > What to use? I think the convention is to use the RubyExceptions.CreateXXXError methods (although I'm not clear on the reason). - John _______________________________________________ Ironruby-core mailing list Ironruby-core at rubyforge.org http://rubyforge.org/mailman/listinfo/ironruby-core From bacondarwin at googlemail.com Thu Dec 6 14:39:53 2007 From: bacondarwin at googlemail.com (Peter Bacon Darwin) Date: Thu, 6 Dec 2007 19:39:53 -0000 Subject: [Ironruby-core] Raising Exceptions In-Reply-To: References: <000001c8380f$6dead2f0$49c078d0$@com> <918705E903F4714CB713D89AB5F1857D738E9E21A7@NA-EXMSG-C116.redmond.corp.microsoft.com> Message-ID: <001101c8383f$c6facf00$54f06d00$@com> Thanks all for the clarification. Will redo the code I have been writing to use RubyExceptions where possible. Cheers, Pete -----Original Message----- From: ironruby-core-bounces at rubyforge.org [mailto:ironruby-core-bounces at rubyforge.org] On Behalf Of Tomas Matousek Sent: Thursday,06 December 06, 2007 19:31 To: ironruby-core at rubyforge.org Subject: Re: [Ironruby-core] Raising Exceptions Yes, use RubyExceptions where possible. Otherwise just throw corresponding BCL exception. We may enrich RubyException class with more commonly thrown exceptions. When we do so, we will search and replace affected throws across the library - that's easy. So if you don't find the exception that should be thrown in this class feel free to just throw the BCL exception directly. The reasons for using RubyExceptions are clarity, code reuse and consistency in error messages. RubyExceptions class should be one of the few places where Ruby to BCL exception mapping takes place - methods on RubyExceptions should be named after Ruby exception classes, so the library writer doesn't need to think about the mapping. The class needs some refactoring though and it should probably be moved to the library. It's on my TODO list to do so. Tomas -----Original Message----- From: ironruby-core-bounces at rubyforge.org [mailto:ironruby-core-bounces at rubyforge.org] On Behalf Of John Messerly Sent: Thursday, December 06, 2007 11:07 AM To: ironruby-core at rubyforge.org Subject: Re: [Ironruby-core] Raising Exceptions Peter Bacon Darwin: > And to add further confusion there are also > RubyExceptions.CreateXXXError methods available. > > What to use? I think the convention is to use the RubyExceptions.CreateXXXError methods (although I'm not clear on the reason). - John _______________________________________________ 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 From bacondarwin at googlemail.com Thu Dec 6 16:54:46 2007 From: bacondarwin at googlemail.com (Peter Bacon Darwin) Date: Thu, 6 Dec 2007 21:54:46 -0000 Subject: [Ironruby-core] MutableString vs string Message-ID: <001201c83852$9eb0cdc0$dc126940$@com> Along the lines of the discussion before about raising exceptions: Is it acceptable to return .NET strings from library methods or should we be trying to use MutableString instances? Pete -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/ironruby-core/attachments/20071206/97c55dcd/attachment.html From eduardofv at gmail.com Thu Dec 6 17:19:27 2007 From: eduardofv at gmail.com (Eduardo A. Flores Verduzco) Date: Thu, 6 Dec 2007 16:19:27 -0600 Subject: [Ironruby-core] MutableString vs string In-Reply-To: <001201c83852$9eb0cdc0$dc126940$@com> References: <001201c83852$9eb0cdc0$dc126940$@com> Message-ID: <57ad48f30712061419t1aba54f6od1eae2a11b564aec@mail.gmail.com> Good question... I'm using always MutableString inside my StringIO implementation but I'm not sure if it's ok... On Dec 6, 2007 3:54 PM, Peter Bacon Darwin wrote: > Along the lines of the discussion before about raising exceptions: Is it > acceptable to return .NET strings from library methods or should we be > trying to use MutableString instances? > > Pete > > _______________________________________________ > Ironruby-core mailing list > Ironruby-core at rubyforge.org > http://rubyforge.org/mailman/listinfo/ironruby-core > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/ironruby-core/attachments/20071206/5fff0e24/attachment.html From Tomas.Matousek at microsoft.com Thu Dec 6 17:59:38 2007 From: Tomas.Matousek at microsoft.com (Tomas Matousek) Date: Thu, 6 Dec 2007 14:59:38 -0800 Subject: [Ironruby-core] MutableString vs string In-Reply-To: <57ad48f30712061419t1aba54f6od1eae2a11b564aec@mail.gmail.com> References: <001201c83852$9eb0cdc0$dc126940$@com> <57ad48f30712061419t1aba54f6od1eae2a11b564aec@mail.gmail.com> Message-ID: You should return MutableStrings and also accept MutableStrings as parameters. Tomas From: ironruby-core-bounces at rubyforge.org [mailto:ironruby-core-bounces at rubyforge.org] On Behalf Of Eduardo A. Flores Verduzco Sent: Thursday, December 06, 2007 2:19 PM To: ironruby-core at rubyforge.org Subject: Re: [Ironruby-core] MutableString vs string Good question... I'm using always MutableString inside my StringIO implementation but I'm not sure if it's ok... On Dec 6, 2007 3:54 PM, Peter Bacon Darwin < bacondarwin at googlemail.com> wrote: Along the lines of the discussion before about raising exceptions: Is it acceptable to return .NET strings from library methods or should we be trying to use MutableString instances? Pete _______________________________________________ Ironruby-core mailing list Ironruby-core at rubyforge.org http://rubyforge.org/mailman/listinfo/ironruby-core -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/ironruby-core/attachments/20071206/2b9bf14a/attachment-0001.html From jomes at microsoft.com Thu Dec 6 23:28:44 2007 From: jomes at microsoft.com (John Messerly) Date: Thu, 6 Dec 2007 20:28:44 -0800 Subject: [Ironruby-core] MutableString vs string In-Reply-To: References: <001201c83852$9eb0cdc0$dc126940$@com> <57ad48f30712061419t1aba54f6od1eae2a11b564aec@mail.gmail.com> Message-ID: <918705E903F4714CB713D89AB5F1857D738E9E2496@NA-EXMSG-C116.redmond.corp.microsoft.com> Tomas: > You should return MutableStrings and also accept MutableStrings as > parameters. Yup. Long term, we've talked about some action binder magic that would automatically convert MutableString <-> System.String for calling .NET methods. But that's a long way off, so use MutableStrings for now. - John From bacondarwin at googlemail.com Tue Dec 11 10:19:27 2007 From: bacondarwin at googlemail.com (Peter Bacon Darwin) Date: Tue, 11 Dec 2007 15:19:27 -0000 Subject: [Ironruby-core] Fixnum Patch Message-ID: <000001c83c09$395abfc0$ac103f40$@com> Overview: The focus of this patch is to implement the Fixnum methods and to provide RSpec tests for those methods. In addition the Bignum methods have been tweaked and the tests for Bignum have been improved by adding more edge cases. The implementation of the Fixnum methods required some methods in other classes to be added or modified. These have not been tested to the same level as the Fixnum and Bignum methods and there may be edge cases that have been missed. To help with running the tests I added a small script, run_builtin.rb that lets you run all the tests for a particular builtin class (such as Fixnum) on both ruby.exe and rbx.exe side by side. I found this particularly useful when writing and testing the specs to see where the work was. Usage is as follows: ruby run_builtin.rb {BuiltinType}, where {BuiltinType} is the name of a folder below the BuiltIn folder containing the specs to run. It assumes that you are running it from the trunk/tests/ironruby folder and that ruby.exe is in the path. E.g. ruby run_builtin.rb Fixnum. Of course, bear in mind that until Bignum gets "switched on" none of the Bignum related functionality will work. Code Change Detail: BignumOps.cs . This file has had a general tidy up. The methods have been reordered and group better. . The CoerceAndCall method has been moved to Numeric. . All exceptions are now created via Ruby.Runtime.RubyExceptions . A number of methods, notably BignumOps.Compare, now return an object rather than a Float (int). This is because these methods sometimes are expected to return nil (null). Comparable.cs . The major change here is that Protocols.Compare is no longer assumed to return a bool and we first test for null before casting the result to an int. FloatOps.cs . Added a number of methods to support the post-coercion calling from Bignum and Fixnum. These methods are not expected to deal with all cases yet. Methods affected include: ceil, floor, to_i, to_int, truncate, to_f and round. . Methods such as <=>, < and divmod have had additional checks put in place to deal with unusual cases of Infinity and NaN. Possibly these will be moved into the Protocols classes in due course? Integer.cs . Added the "integer?" method. Numeric.cs . Implemented all the Numeric instance methods. These have not been subject to rigorous unit testing yet. . Implemented a number of helper methods, used by the other Numeric classes such as Bignum and Fixnum: CoerceAndCall, CoerceAndCallCompare, CoerceAndCallRelationOperator, MakeCoercionError and MakeComparisonError. . Also added the singleton_method_added method. But currently this does not get called as it has not yet been defined in Object (Kernel). NumericSites.cs . Added a number of additional sites to support the Numeric classes. . The NumericSites.Coerce method now does some additional checks on what is returned from the invocation. ObjectOps.cs . Added inspect and new methods. These help creating the fixtures for the Fixnum and Bignum tests. SymbolOps.cs . Fixed ToString to return null if the symbol does not exist in the SymbolTable. . Fixed Inspect accordingly. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/ironruby-core/attachments/20071211/0ce0f0c4/attachment-0001.html -------------- next part -------------- A non-text attachment was scrubbed... Name: FixnumMethods.patch Type: application/octet-stream Size: 243956 bytes Desc: not available Url : http://rubyforge.org/pipermail/ironruby-core/attachments/20071211/0ce0f0c4/attachment-0001.obj From jflam at microsoft.com Tue Dec 11 14:06:03 2007 From: jflam at microsoft.com (John Lam (DLR)) Date: Tue, 11 Dec 2007 11:06:03 -0800 Subject: [Ironruby-core] Fixnum Patch In-Reply-To: <000001c83c09$395abfc0$ac103f40$@com> References: <000001c83c09$395abfc0$ac103f40$@com> Message-ID: <372109E149E8084D8E6C7D9CFD82E06329DB899FA2@NA-EXMSG-C115.redmond.corp.microsoft.com> Peter Bacon Darwin: > Subject: [Ironruby-core] Fixnum Patch > > Overview: > ... Thanks for sending in this patch, Peter! We'll review and integrate ASAP. We'll do the fixes in Protocols to get the tests to pass as well. -John From bcardiff at gmail.com Wed Dec 12 08:55:34 2007 From: bcardiff at gmail.com (Brian J. Cardiff) Date: Wed, 12 Dec 2007 10:55:34 -0300 Subject: [Ironruby-core] Fixnum Patch In-Reply-To: <000001c83c09$395abfc0$ac103f40$@com> References: <000001c83c09$395abfc0$ac103f40$@com> Message-ID: <190204680712120555w52a967e0y567e97bfb2acd039@mail.gmail.com> On Dec 11, 2007 12:19 PM, Peter Bacon Darwin wrote: > > > ? A number of methods, notably BignumOps.Compare, now return an > object rather than a Float (int). This is because these methods sometimes > are expected to return nil (null). > wouldn't be better to use nullable types? So, for example, it would be clear that the result is either null or int, and there is not propagation of casts. -- Brian J. Cardiff bcardiff(?)gmail.com . From bacondarwin at googlemail.com Wed Dec 12 09:56:37 2007 From: bacondarwin at googlemail.com (Peter Bacon Darwin) Date: Wed, 12 Dec 2007 14:56:37 -0000 Subject: [Ironruby-core] Fixnum Patch In-Reply-To: <190204680712120555w52a967e0y567e97bfb2acd039@mail.gmail.com> References: <000001c83c09$395abfc0$ac103f40$@com> <190204680712120555w52a967e0y567e97bfb2acd039@mail.gmail.com> Message-ID: <000c01c83ccf$352170e0$9f6452a0$@com> Brian J. Cardiff wrote: > wouldn't be better to use nullable types? So, for example, it would be > clear that the result is either null or int, and there is not > propagation of casts. This is a fair comment and one that I did consider. I am generally a bit weary of Nullable types and I didn't feel overly confident in using them in library code (how often do you actually see them used in practice?). This is no excuse of course. The two reasons in favour of using NullableTypes as I see them are clarity and performance. Clarity Ruby doesn't really appear to care much about the return type on the method itself; it is more interested in the object that is returned; and so the user of the class (in Ruby) won't be able to tell the difference anyway. There are other cases where object is returned regularly In fact almost all the Bignum methods return object since the result may well be converted to a Fixnum (if it is small enough) or even a Float (if the result is not supposed to be Integer). Performance In the end there is not much gained in using more specific types in these cases. The only reason would be for performance (saving the cost of Boxing or casting) but to get to the value of a Nullable type you still have to check whether it is null and then access the Value property anyway so there is probably not much in it. public int? Compare(BigInteger self, BigInteger other) leads to code like int? result = Compare(someBigInt, otherBigInt); if (result.HasValue) { int actualResult = result.Value // Do something with it } else { // Do something with null } public object Compare(BigInteger self, BigInteger other) leads to code like object result = Compare(someBigInt, otherBigInt); if (result is int) { int actualResult = (int)result; // Do something with it } else { // Do something with null } The main reason I kept away from using them, was that it keeps the options open and is more in keeping with the general style of the library code. Am I barking up the wrong tree here? I may well be missing something. Let me know what you think. Pete -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/ironruby-core/attachments/20071212/2cfee3b9/attachment.html From bcardiff at gmail.com Wed Dec 12 11:32:14 2007 From: bcardiff at gmail.com (Brian J. Cardiff) Date: Wed, 12 Dec 2007 13:32:14 -0300 Subject: [Ironruby-core] Fixnum Patch In-Reply-To: <000c01c83ccf$352170e0$9f6452a0$@com> References: <000001c83c09$395abfc0$ac103f40$@com> <190204680712120555w52a967e0y567e97bfb2acd039@mail.gmail.com> <000c01c83ccf$352170e0$9f6452a0$@com> Message-ID: <190204680712120832m52c3d3c1l703d7097ce606144@mail.gmail.com> I agree in the pros of using nullable: Clarity and Performance. Also my previous mail was inspired in what your original need: returns int or null, so using Nullable it seems to be the smallest solution. But I didn't have in mind if there are some issues in exposing them to the ruby engine. On Dec 12, 2007 11:56 AM, Peter Bacon Darwin wrote: > > > > > Brian J. Cardiff wrote: > > > wouldn't be better to use nullable types? So, for example, it would be > > > clear that the result is either null or int, and there is not > > > propagation of casts. > > > > > > This is a fair comment and one that I did consider. > > > > I am generally a bit weary of Nullable types and I didn't feel overly > confident in using them in library code (how often do you actually see them > used in practice?). This is no excuse of course. > > > > The two reasons in favour of using NullableTypes as I see them are clarity > and performance. > > > > Clarity > > Ruby doesn't really appear to care much about the return type on the method > itself; it is more interested in the object that is returned; and so the > user of the class (in Ruby) won't be able to tell the difference anyway. > There are other cases where object is returned regularly > > In fact almost all the Bignum methods return object since the result may > well be converted to a Fixnum (if it is small enough) or even a Float (if > the result is not supposed to be Integer). > > > > Performance > > In the end there is not much gained in using more specific types in these > cases. The only reason would be for performance (saving the cost of Boxing > or casting) but to get to the value of a Nullable type you still have to > check whether it is null and then access the Value property anyway so there > is probably not much in it. > > > > public int? Compare(BigInteger self, BigInteger other) > > leads to code like > > int? result = Compare(someBigInt, otherBigInt); > > if (result.HasValue) { > > int actualResult = result.Value > > // Do something with it > > } else { > > // Do something with null > > } > > > > public object Compare(BigInteger self, BigInteger other) > > leads to code like > > object result = Compare(someBigInt, otherBigInt); > > if (result is int) { > > int actualResult = (int)result; > > // Do something with it > > } else { > > // Do something with null > > } > > > > The main reason I kept away from using them, was that it keeps the options > open and is more in keeping with the general style of the library code. > > > > Am I barking up the wrong tree here? I may well be missing something. Let > me know what you think. > > > > Pete > _______________________________________________ > Ironruby-core mailing list > Ironruby-core at rubyforge.org > http://rubyforge.org/mailman/listinfo/ironruby-core > > -- Brian J. Cardiff bcardiff(?)gmail.com . From jomes at microsoft.com Wed Dec 12 16:07:39 2007 From: jomes at microsoft.com (John Messerly) Date: Wed, 12 Dec 2007 13:07:39 -0800 Subject: [Ironruby-core] Fixnum Patch In-Reply-To: <190204680712120832m52c3d3c1l703d7097ce606144@mail.gmail.com> References: <000001c83c09$395abfc0$ac103f40$@com> <190204680712120555w52a967e0y567e97bfb2acd039@mail.gmail.com> <000c01c83ccf$352170e0$9f6452a0$@com> <190204680712120832m52c3d3c1l703d7097ce606144@mail.gmail.com> Message-ID: <918705E903F4714CB713D89AB5F1857D738EBC3395@NA-EXMSG-C116.redmond.corp.microsoft.com> Brian J. Cardiff wrote: > I agree in the pros of using nullable: Clarity and Performance. > > Also my previous mail was inspired in what your original need: returns > int or null, so using Nullable it seems to be the smallest > solution. But I didn't have in mind if there are some issues in > exposing them to the ruby engine. Definitely a good thing to do--as long as we actually handle Nullable correctly. Off the top of my head I'm not sure. Worth trying though. For better or worse, there are a lot of methods that need to have their return types typed to System.Object. Methods that take blocks usually need to return object (in case the block breaks with an arbitrary object, which we need to pass through). Also if you're calling back through a dynamic site into Ruby code, even if the method should normally return a particular type (for example, <=> is supposed to return Fixnum +1, 0, or -1), nothing stops the user from returning whatever they want. We actually don't get this right today in several places. (Ah, the fun of implementing a dynamically typed language in a statically typed one :-) ) - John From jomes at microsoft.com Wed Dec 12 16:12:02 2007 From: jomes at microsoft.com (John Messerly) Date: Wed, 12 Dec 2007 13:12:02 -0800 Subject: [Ironruby-core] Fixnum Patch References: <000001c83c09$395abfc0$ac103f40$@com> <190204680712120555w52a967e0y567e97bfb2acd039@mail.gmail.com> <000c01c83ccf$352170e0$9f6452a0$@com> <190204680712120832m52c3d3c1l703d7097ce606144@mail.gmail.com> Message-ID: <918705E903F4714CB713D89AB5F1857D738EBC33A0@NA-EXMSG-C116.redmond.corp.microsoft.com> John Messerly: > Definitely a good thing to do--as long as we actually handle > Nullable correctly. Off the top of my head I'm not sure. Worth > trying though. Oh, and just to be clear, what I mean is if you try to examine the resulting object, does the resulting object show up as a real Fixnum/NilClass? I'm afraid it might come through as an instance of Nullable, which wouldn't be right. If it does, work we need to fix it, but the workaround for now would be to return an object. - John From bacondarwin at googlemail.com Wed Dec 12 16:33:01 2007 From: bacondarwin at googlemail.com (Peter Bacon Darwin) Date: Wed, 12 Dec 2007 21:33:01 -0000 Subject: [Ironruby-core] Fixnum Patch In-Reply-To: <918705E903F4714CB713D89AB5F1857D738EBC3395@NA-EXMSG-C116.redmond.corp.microsoft.com> References: <000001c83c09$395abfc0$ac103f40$@com> <190204680712120555w52a967e0y567e97bfb2acd039@mail.gmail.com> <000c01c83ccf$352170e0$9f6452a0$@com> <190204680712120832m52c3d3c1l703d7097ce606144@mail.gmail.com> <918705E903F4714CB713D89AB5F1857D738EBC3395@NA-EXMSG-C116.redmond.corp.microsoft.com> Message-ID: <001f01c83d06$93ef49d0$bbcddd70$@com> What John discusses below was part of the reason I was wary (not weary!) of using Nullable types. I have now tested it and if you have a method that, for instance, returns int? then on the occasions that null is returned that class of the resulting object is NilClass and when it is not null, the class is Fixnum. So all seems to be well and I am happy to fix-up those methods in Bignum and Fixnum that should use Nullable types when I next submit a patch. Thanks for pointing this out. Pete -----Original Message----- From: ironruby-core-bounces at rubyforge.org [mailto:ironruby-core-bounces at rubyforge.org] On Behalf Of John Messerly Sent: Wednesday,12 December 12, 2007 21:08 To: ironruby-core at rubyforge.org Subject: Re: [Ironruby-core] Fixnum Patch Brian J. Cardiff wrote: > I agree in the pros of using nullable: Clarity and Performance. > > Also my previous mail was inspired in what your original need: returns > int or null, so using Nullable it seems to be the smallest > solution. But I didn't have in mind if there are some issues in > exposing them to the ruby engine. Definitely a good thing to do--as long as we actually handle Nullable correctly. Off the top of my head I'm not sure. Worth trying though. For better or worse, there are a lot of methods that need to have their return types typed to System.Object. Methods that take blocks usually need to return object (in case the block breaks with an arbitrary object, which we need to pass through). Also if you're calling back through a dynamic site into Ruby code, even if the method should normally return a particular type (for example, <=> is supposed to return Fixnum +1, 0, or -1), nothing stops the user from returning whatever they want. We actually don't get this right today in several places. (Ah, the fun of implementing a dynamically typed language in a statically typed one :-) ) - John _______________________________________________ Ironruby-core mailing list Ironruby-core at rubyforge.org http://rubyforge.org/mailman/listinfo/ironruby-core From jomes at microsoft.com Wed Dec 12 16:53:06 2007 From: jomes at microsoft.com (John Messerly) Date: Wed, 12 Dec 2007 13:53:06 -0800 Subject: [Ironruby-core] Fixnum Patch In-Reply-To: <001f01c83d06$93ef49d0$bbcddd70$@com> References: <000001c83c09$395abfc0$ac103f40$@com> <190204680712120555w52a967e0y567e97bfb2acd039@mail.gmail.com> <000c01c83ccf$352170e0$9f6452a0$@com> <190204680712120832m52c3d3c1l703d7097ce606144@mail.gmail.com> <918705E903F4714CB713D89AB5F1857D738EBC3395@NA-EXMSG-C116.redmond.corp.microsoft.com> <001f01c83d06$93ef49d0$bbcddd70$@com> Message-ID: <918705E903F4714CB713D89AB5F1857D738EBC33DF@NA-EXMSG-C116.redmond.corp.microsoft.com> Peter Bacon Darwin: > I have now tested it and if you have a method that, for instance, > returns int? then on the occasions that null is returned that class of > the resulting object is NilClass and when it is not null, the class is > Fixnum. So all seems to be well and I am happy to fix-up those methods > in Bignum and Fixnum that should use Nullable types when I next submit > a patch. I love it when stuff just works :) - John From jomes at microsoft.com Wed Dec 12 18:04:58 2007 From: jomes at microsoft.com (John Messerly) Date: Wed, 12 Dec 2007 15:04:58 -0800 Subject: [Ironruby-core] Fixnum Patch In-Reply-To: <001f01c83d06$93ef49d0$bbcddd70$@com> References: <000001c83c09$395abfc0$ac103f40$@com> <190204680712120555w52a967e0y567e97bfb2acd039@mail.gmail.com> <000c01c83ccf$352170e0$9f6452a0$@com> <190204680712120832m52c3d3c1l703d7097ce606144@mail.gmail.com> <918705E903F4714CB713D89AB5F1857D738EBC3395@NA-EXMSG-C116.redmond.corp.microsoft.com> <001f01c83d06$93ef49d0$bbcddd70$@com> Message-ID: <918705E903F4714CB713D89AB5F1857D738EBC346B@NA-EXMSG-C116.redmond.corp.microsoft.com> Peter Bacon Darwin: > What John discusses below was part of the reason I was wary (not > weary!) of using Nullable types. > > I have now tested it and if you have a method that, for instance, > returns int? then on the occasions that null is returned that class of > the resulting object is NilClass and when it is not null, the class is > Fixnum. So all seems to be well and I am happy to fix-up those methods > in Bignum and Fixnum that should use Nullable types when I next submit > a patch. On second thought, it might be better to not use Nullable. As Dino & Tomas pointed out, now we're playing games with our type system, because to the CLR Int32 and Nullable are different types. For example, if you have a CLR method "foo" that returns Nullable: x = obj.foo # x is now a Nullable 5 + x # this is probably okay; the method binder converts Nullable arguments to Int32 x + 5 # how does this work? Nullable doesn't define the Ruby method "+" Since x is a Nullable, we should be looking up method calls on Nullable. But that won't work... Actually, it might be a bug that it's working now. Probably better to just leave return values as "object". - John From lists at ruby-forum.com Fri Dec 14 09:48:24 2007 From: lists at ruby-forum.com (N. F.) Date: Fri, 14 Dec 2007 15:48:24 +0100 Subject: [Ironruby-core] IronRuby and MarkLogic In-Reply-To: <918705E903F4714CB713D89AB5F1857D738E8C6586@NA-EXMSG-C116.redmond.corp.microsoft.com> References: <372109E149E8084D8E6C7D9CFD82E06329DB623698@NA-EXMSG-C115.redmond.corp.microsoft.com> <75f192a57ebd31511ac864d1101e95aa@ruby-forum.com> <918705E903F4714CB713D89AB5F1857D738E8C6137@NA-EXMSG-C116.redmond.corp.microsoft.com> <13f5089658d136717f882cf693cf5a89@ruby-forum.com> <918705E903F4714CB713D89AB5F1857D738E8C6586@NA-EXMSG-C116.redmond.corp.microsoft.com> Message-ID: <83fbe5c2780512469056ee889bd5de5f@ruby-forum.com> John Messerly wrote: > > Yup, I think you found the problem. I didn't get a chance to look at it > today, but I'll take a look at it Monday (unless I can get Tomas to fix > it :) ). Hopefully it's an easy fix > > - John Hi John, do you (or Tomas) still plan to take a look at this? Thanks! -- Posted via http://www.ruby-forum.com/. From bacondarwin at googlemail.com Fri Dec 14 15:25:54 2007 From: bacondarwin at googlemail.com (Peter Bacon Darwin) Date: Fri, 14 Dec 2007 20:25:54 -0000 Subject: [Ironruby-core] Fixnum Patch In-Reply-To: <918705E903F4714CB713D89AB5F1857D738EBC346B@NA-EXMSG-C116.redmond.corp.microsoft.com> References: <000001c83c09$395abfc0$ac103f40$@com> <190204680712120555w52a967e0y567e97bfb2acd039@mail.gmail.com> <000c01c83ccf$352170e0$9f6452a0$@com> <190204680712120832m52c3d3c1l703d7097ce606144@mail.gmail.com> <918705E903F4714CB713D89AB5F1857D738EBC3395@NA-EXMSG-C116.redmond.corp.microsoft.com> <001f01c83d06$93ef49d0$bbcddd70$@com> <918705E903F4714CB713D89AB5F1857D738EBC346B@NA-EXMSG-C116.redmond.corp.microsoft.com> Message-ID: <000501c83e8f$88198b40$984ca1c0$@com> As it turns out, since there is loads of boxing going on in IronRuby/DLR you do actually get the right semantics for free. When a nullable value type is boxed you either get a null reference or a boxed version of the underlying value type. Great! This means that, since all dynamic invocations go via methods that look like this (note the "object" return type): public override object Invoke(object arg0) { return _target(arg0 != null ? (T0)arg0 : default(T0)); } The nullable type gets converted into a regular null or boxed value type. You can see this happen if you step through the code. It is a bit creepy actually. The DLR knows that the return type of a method is actually a Nullable but the actual value is either a null or Int32. The example given below, therefore, does actually do what you want it to. The value of x actually is a Fixnum and so works like a treat. This is still all a bit scary and I personally think keeping object rather than int? is safer and doesn't detract from the clarity. Also, since there is all this boxing going on anyway you get no performance benefit either. Pete John Messerly wrote: >> On second thought, it might be better to not use Nullable. As Dino & Tomas pointed out, now we're playing games with our >> type system, because to the CLR Int32 and Nullable are different types. For example, if you have a CLR method "foo" that >> returns Nullable: >> >> x = obj.foo # x is now a Nullable >> 5 + x # this is probably okay; the method binder converts Nullable arguments to Int32 >> x + 5 # how does this work? Nullable doesn't define the Ruby method "+" >> >> Since x is a Nullable, we should be looking up method calls on Nullable. But that won't work... >> >> Actually, it might be a bug that it's working now. Probably better to just leave return values as "object". >> >> - John From jomes at microsoft.com Sun Dec 16 22:38:20 2007 From: jomes at microsoft.com (John Messerly) Date: Sun, 16 Dec 2007 19:38:20 -0800 Subject: [Ironruby-core] Fixnum Patch In-Reply-To: <000501c83e8f$88198b40$984ca1c0$@com> References: <000001c83c09$395abfc0$ac103f40$@com> <190204680712120555w52a967e0y567e97bfb2acd039@mail.gmail.com> <000c01c83ccf$352170e0$9f6452a0$@com> <190204680712120832m52c3d3c1l703d7097ce606144@mail.gmail.com> <918705E903F4714CB713D89AB5F1857D738EBC3395@NA-EXMSG-C116.redmond.corp.microsoft.com> <001f01c83d06$93ef49d0$bbcddd70$@com> <918705E903F4714CB713D89AB5F1857D738EBC346B@NA-EXMSG-C116.redmond.corp.microsoft.com> <000501c83e8f$88198b40$984ca1c0$@com> Message-ID: <918705E903F4714CB713D89AB5F1857D73A79302DE@NA-EXMSG-C116.redmond.corp.microsoft.com> Peter Bacon Darwin: > As it turns out, since there is loads of boxing going on in > IronRuby/DLR you do actually get the right semantics for free. > > Nice job tracking that one down. Makes a lot more sense now. > This is still all a bit scary and I personally think keeping object > rather than int? is safer and doesn't detract from the clarity. Also, > since there is all this boxing going on anyway you get no performance > benefit either. Agreed. I think it's safe to say the current behavior is an implementation side effect, not something to be relied on at this point. - John From jomes at microsoft.com Sun Dec 16 22:59:31 2007 From: jomes at microsoft.com (John Messerly) Date: Sun, 16 Dec 2007 19:59:31 -0800 Subject: [Ironruby-core] IronRuby and MarkLogic In-Reply-To: <83fbe5c2780512469056ee889bd5de5f@ruby-forum.com> References: <372109E149E8084D8E6C7D9CFD82E06329DB623698@NA-EXMSG-C115.redmond.corp.microsoft.com> <75f192a57ebd31511ac864d1101e95aa@ruby-forum.com> <918705E903F4714CB713D89AB5F1857D738E8C6137@NA-EXMSG-C116.redmond.corp.microsoft.com> <13f5089658d136717f882cf693cf5a89@ruby-forum.com> <918705E903F4714CB713D89AB5F1857D738E8C6586@NA-EXMSG-C116.redmond.corp.microsoft.com> <83fbe5c2780512469056ee889bd5de5f@ruby-forum.com> Message-ID: <918705E903F4714CB713D89AB5F1857D73A79302E2@NA-EXMSG-C116.redmond.corp.microsoft.com> N.F.: > Hi John, do you (or Tomas) still plan to take a look at this? Thanks! Thanks for the ping. I think the simple fix actually works fine here. Let me know if it works for you & I'll get it checked in. - John Index: src/ironruby/Runtime/RubyModule.cs =================================================================== --- src/ironruby/Runtime/RubyModule.cs (revision 66) +++ src/ironruby/Runtime/RubyModule.cs (working copy) @@ -483,8 +483,8 @@ return true; } - // skip lookup on types that are not visible or interfaces: - if (_tracker != null && _tracker.Type.IsVisible && !_tracker.Type.IsInterface) { + // skip lookup on interfaces: + if (_tracker != null && !_tracker.Type.IsInterface) { return TryGetClrMember(_tracker.Type, name, out method); } From jflam at microsoft.com Mon Dec 17 12:51:29 2007 From: jflam at microsoft.com (John Lam (DLR)) Date: Mon, 17 Dec 2007 09:51:29 -0800 Subject: [Ironruby-core] FW: Review of Peter Bacon Darwin's Fixnum patch Message-ID: <372109E149E8084D8E6C7D9CFD82E06329DC62D61D@NA-EXMSG-C115.redmond.corp.microsoft.com> FYI We did this internal review last week (we had a ski day interfere with work on Friday :))- am working on some minor changes to the shelveset before checking in later today. Thanks! -John From: John Messerly Sent: Thursday, December 13, 2007 8:45 PM To: John Lam (DLR); IronRuby Team Subject: RE: Review of Peter Bacon Darwin's Fixnum patch [inline] From: John Lam (DLR) Sent: Thursday, December 13, 2007 7:28 PM To: IronRuby Team Subject: Review of Peter Bacon Darwin's Fixnum patch tfpt review /shelveset:FixnumPatch;jflam My initial look: ObjectOps.cs: I don't understand why he's re-implementing new and inspect here - should revert this change. [jomes] He's fixing our "inspect" method to call "to_s" if available. The change is correct: irb(main):001:0> class Bob irb(main):002:1> def to_s; "abc"; end irb(main):003:1> end => nil irb(main):004:0> Bob.new => abc >>> ^Z But it should be in ObjectOps. But I'm not sure about Object.new, probably ask why he added that FixnumOps.cs (388): I don't understand why he's converting the Fixnum into a Bignum before doing the power operation. [jomes] probably to get overflow right without a try-catch... also Math.Pow takes doubles There appears to be a duplicate NumericSites.Equal and RubySites.Equal. After looking a bit more, it seems like we should introduce a new protocol: public static bool IsEqual(CodeContext context, object lhs, object rhs) { return Protocol.IsTrue(RubySites.Equal(context, lhs, rhs)); } We should move RubyOps.IsTrue to Protocols. Some usage of RubySites.ToInt instead of Protocols.ToInt. Should we remove RubySites.ToInt altogether? Numeric.CoerceAndCall is used in a lot of places - looks like a good candidate to make into a Protocol. [jomes] agreed about all the protocol stuff-needs to be consistent & in Protocols.cs (actually, is this file in IronRuby.dll or Libraries? Maybe that was why he didn't put them there). The general pattern I've noticed is that sites are not normally needed from library methods (except block sites). Also, Comparable uses this pattern everywhere now: object result = Protocols.Compare(context, self, other); if (result == null) { Numeric.MakeComparisonError(context, self, other); } Which looks correct, but should be baked into the Protocol itself. There's some code duplication in Numeric.Step which could be simplified In Numeric.YieldStep, if the BlockJumped he's not returning the value that the block returned. But maybe that isn't necessary? Tomas would know for sure. I think singleton_method_added shouldn't be on Numeric.... Probably we should throw instead when you try to define a singleton method (or any instance data) on an immediate value. (Ruby immediate values are true, false, nil, Fixnums, and Symbols. We have a check for this in RubyUtils.IsRubyValueType. But we don't think we enforce that you can't add singleton methods on them.) Thanks, -John -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/ironruby-core/attachments/20071217/58c5dd1e/attachment-0001.html From lists at ruby-forum.com Mon Dec 17 15:02:49 2007 From: lists at ruby-forum.com (N. F.) Date: Mon, 17 Dec 2007 21:02:49 +0100 Subject: [Ironruby-core] IronRuby and MarkLogic In-Reply-To: <918705E903F4714CB713D89AB5F1857D73A79302E2@NA-EXMSG-C116.redmond.corp.microsoft.com> References: <372109E149E8084D8E6C7D9CFD82E06329DB623698@NA-EXMSG-C115.redmond.corp.microsoft.com> <75f192a57ebd31511ac864d1101e95aa@ruby-forum.com> <918705E903F4714CB713D89AB5F1857D738E8C6137@NA-EXMSG-C116.redmond.corp.microsoft.com> <13f5089658d136717f882cf693cf5a89@ruby-forum.com> <918705E903F4714CB713D89AB5F1857D738E8C6586@NA-EXMSG-C116.redmond.corp.microsoft.com> <83fbe5c2780512469056ee889bd5de5f@ruby-forum.com> <918705E903F4714CB713D89AB5F1857D73A79302E2@NA-EXMSG-C116.redmond.corp.microsoft.com> Message-ID: John Messerly wrote: > Thanks for the ping. I think the simple fix actually works fine here. > Let me know if it works for you & I'll get it checked in. Hi John...it worked great! Thanks so very much...I went ahead and pulled the record from the MarkLogic server and all looks good. Here is the sample code (very basic...just to show it works) in case anyone may care: require 'System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' require "c:\\IronRuby\\build\\release\\MarklogicXcc.dll" # all xcc dlls have to be in the same dir as ironruby (except for MarklogicXcc.dll) uri = System::Uri.new('xcc://adm:adm at localhost:9003') content_source = Marklogic::Xcc::ContentSourceFactory::NewContentSource(uri) session = content_source::NewSession() query = 'let $r := //Record[@UID eq "200608199-060"] return $r' request = session.NewAdhocQuery(query) resultSequence = session.SubmitRequest(request) results = resultSequence.AsString("/n") puts results -- Nivaldo -- Posted via http://www.ruby-forum.com/. From bacondarwin at googlemail.com Mon Dec 17 15:05:11 2007 From: bacondarwin at googlemail.com (Peter Bacon Darwin) Date: Mon, 17 Dec 2007 20:05:11 -0000 Subject: [Ironruby-core] FW: Review of Peter Bacon Darwin's Fixnum patch In-Reply-To: <372109E149E8084D8E6C7D9CFD82E06329DC62D61D@NA-EXMSG-C115.redmond.corp.microsoft.com> References: <372109E149E8084D8E6C7D9CFD82E06329DC62D61D@NA-EXMSG-C115.redmond.corp.microsoft.com> Message-ID: <002d01c840e8$222a3180$667e9480$@com> Thanks for doing the review of the contribution. Hope you enjoyed the skiing! I have added my own comments and answered your questions inline below: Pete From: John Lam (DLR) Sent: Thursday, December 13, 2007 7:28 PM To: IronRuby Team Subject: Review of Peter Bacon Darwin's Fixnum patch tfpt review /shelveset:FixnumPatch;jflam My initial look: ObjectOps.cs: I don't understand why he's re-implementing new and inspect here - should revert this change. [jomes] He's fixing our "inspect" method to call "to_s" if available. The change is correct: irb(main):001:0> class Bob irb(main):002:1> def to_s; "abc"; end irb(main):003:1> end => nil irb(main):004:0> Bob.new => abc >>> ^Z But it should be in ObjectOps. But I'm not sure about Object.new, probably ask why he added that [Pete] Yes, there was a small issue with inspect that was causing some of the Fixnum tests to fail. I added ObjectOps.New because without it you couldn't instantiate a instance of Object. Object is not an abstract class. I believe that this is quite common Ruby behavior, as you can then add singleton methods to the object that is created. This is exactly what I have done to create specific object that respond in certain ways as fixtures in some of the tests. FixnumOps.cs (388): I don't understand why he's converting the Fixnum into a Bignum before doing the power operation. [jomes] probably to get overflow right without a try-catch. also Math.Pow takes doubles [Pete] I suppose I was being a bit lazy: As John notes Math.Pow takes doubles so couldn't rely on that producing the same result; rather than code up the whole algorithm again from scratch I just reused the BigInteger method. This can be fixed up if there is a performance issue. There appears to be a duplicate NumericSites.Equal and RubySites.Equal. After looking a bit more, it seems like we should introduce a new protocol: public static bool IsEqual(CodeContext context, object lhs, object rhs) { return Protocol.IsTrue(RubySites.Equal(context, lhs, rhs)); } We should move RubyOps.IsTrue to Protocols. [Pete] I agree with having Protocols.IsEqual and Protocols.IsTrue. Sorry I unnecessarily added the NumericSites.Equal method. Some usage of RubySites.ToInt instead of Protocols.ToInt. Should we remove RubySites.ToInt altogether? [Pete] There are points in MRI where only to_int and the full conversion protocol is not followed. It may be that this is an oversight in the implementation. I expect that the behavior would be equivalent, so I will revert to using Protocols.ConvertToInteger instead. Numeric.CoerceAndCall is used in a lot of places - looks like a good candidate to make into a Protocol. [Pete] Absolutely, along with CoerceAndCallCompare and CoerceAndCallRelationOperator Also Numeric.MakeCoercionError and Numeric.MakeComparisonError could be moved to RubyExceptions. [jomes] agreed about all the protocol stuff-needs to be consistent & in Protocols.cs (actually, is this file in IronRuby.dll or Libraries? Maybe that was why he didn't put them there). [Pete] Protocols.cs and of course RubySites.cs are indeed in IronRuby.dll, so that is why I have been using Numeric.cs and NumericSites.cs to catch these general cases. The general pattern I've noticed is that sites are not normally needed from library methods (except block sites). [Pete] Not sure what you mean here. All the sites I created in NumericSites are being used in the Numeric classes; look at all the calls to CoerceAndCall. Also, Comparable uses this pattern everywhere now: object result = Protocols.Compare(context, self, other); if (result == null) { Numeric.MakeComparisonError(context, self, other); } Which looks correct, but should be baked into the Protocol itself. [Pete] I agree, but I couldn't see how to easily pull it out of each method without making the methods less clear and not jumping through unnecessary coding hoops. There's some code duplication in Numeric.Step which could be simplified [Pete] The trouble with the duplication is that it is Type specific. Perhaps this could be achieved with a generic method? In Numeric.YieldStep, if the BlockJumped he's not returning the value that the block returned. But maybe that isn't necessary? Tomas would know for sure. [Pete] You could well be right here. I can look into it if you want. I think singleton_method_added shouldn't be on Numeric.. Probably we should throw instead when you try to define a singleton method (or any instance data) on an immediate value. (Ruby immediate values are true, false, nil, Fixnums, and Symbols. We have a check for this in RubyUtils.IsRubyValueType. But we don't think we enforce that you can't add singleton methods on them.) [Pete] This sounds like a good idea, unless one can monkey-patch the behavior in Ruby by overriding the singleton_method_added method. I suspect this is not what was intended and blocking it at the immediate value level is the correct way to go. Thanks, -John -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/ironruby-core/attachments/20071217/4ff9f857/attachment.html From jomes at microsoft.com Mon Dec 17 17:55:03 2007 From: jomes at microsoft.com (John Messerly) Date: Mon, 17 Dec 2007 14:55:03 -0800 Subject: [Ironruby-core] FW: Review of Peter Bacon Darwin's Fixnum patch In-Reply-To: <002d01c840e8$222a3180$667e9480$@com> References: <372109E149E8084D8E6C7D9CFD82E06329DC62D61D@NA-EXMSG-C115.redmond.corp.microsoft.com> <002d01c840e8$222a3180$667e9480$@com> Message-ID: <918705E903F4714CB713D89AB5F1857D73A79306C3@NA-EXMSG-C116.redmond.corp.microsoft.com> Peter Bacon Darwin: > [Pete] Yes, there was a small issue with inspect that was causing > some of the Fixnum tests to fail. Yup--just needs to be moved to Kernel.cs. John, are you fixing this? > I added ObjectOps.New because without it you couldn't instantiate a > instance of Object. Object is not an abstract class. I believe that > this is quite common Ruby behavior, as you can then add singleton > methods to the object that is created. This is exactly what I have > done to create specific object that respond in certain ways as > fixtures in some of the tests. I don't understand. I can type Object.new at an IronRuby console and it just works: >>> $x = Object.new => # >>> def $x.foo; "called foo"; end => nil >>> $x.foo => "called foo" (the method binder finds the CLR System.Object constructor & calls it) In what case doesn't it work? > I suppose I was being a bit lazy: As John notes Math.Pow takes > doubles so couldn't rely on that producing the same result; rather > than code up the whole algorithm again from scratch I just reused the > BigInteger method. This can be fixed up if there is a performance > issue. Agreed. I say we keep the code as is & then change it if it proves to be a performance bottleneck. > There are points in MRI where only to_int and the full > conversion protocol is not followed. It may be that this is an > oversight in the implementation. I expect that the behavior would be > equivalent, so I will revert to using Protocols.ConvertToInteger > instead. If so, could we create new protocols? Or are the conversions really only used in one place? If that's the case, then it's fine to call "to_int" directly. But so far most of the conversion protocols seem to recur often (I'm guessing they're C macros/helper functions in MRI) > Protocols.cs and of course RubySites.cs are indeed in > IronRuby.dll, so that is why I have been using Numeric.cs and > NumericSites.cs to catch these general cases. Yeah, I think we should move Protocols to IronRuby.Libraries. Well, feel free to add code there in the meantime--it's library functionality anyway. >> Also, Comparable uses this pattern everywhere now: >> >> object result = Protocols.Compare(context, self, other); >> if (result == null) { >> Numeric.MakeComparisonError(context, self, other); >> } >> >> Which looks correct, but should be baked into the Protocol itself. > > [Pete] I agree, but I couldn't see how to easily pull it out of each > method without making the methods less clear and not jumping through > unnecessary coding hoops. I just mean that it could go in Protocols.Compare itself. I'm guessing that most places will throw if the comparer returns nil. If not, we can make Protocols.TryCompare & Protocols.Compare--the latter will throw. >> There's some code duplication in Numeric.Step which could be >> simplified > > [Pete] The trouble with the duplication is that it is Type specific. > Perhaps this could be achieved with a generic method? Yeah, if possible. But if there's no obvious way to clean it up, don't worry about it. >> In Numeric.YieldStep, if the BlockJumped he's not returning the value >> that the block returned. But maybe that isn't necessary? Tomas would >> know for sure. > > [Pete] You could well be right here. I can look into it if you want. That would be great. The question is: if you break from the block, does the correct value get returned? My understanding was that you had to return the value the block returned, but maybe that isn't required. >> I think singleton_method_added shouldn't be on Numeric.... Probably we >> should throw instead when you try to define a singleton method (or any >> instance data) on an immediate value. (Ruby immediate values are true, >> false, nil, Fixnums, and Symbols. We have a check for this in >> RubyUtils.IsRubyValueType. But I don't think we enforce that you >> can't add singleton methods on them.) > > [Pete] This sounds like a good idea, unless one can monkey-patch the > behavior in Ruby by overriding the singleton_method_added method. I > suspect this is not what was intended and blocking it at the immediate > value level is the correct way to go. Yup. - John From bacondarwin at googlemail.com Tue Dec 18 14:04:18 2007 From: bacondarwin at googlemail.com (Peter Bacon Darwin) Date: Tue, 18 Dec 2007 19:04:18 -0000 Subject: [Ironruby-core] FW: Review of Peter Bacon Darwin's Fixnum patch In-Reply-To: <918705E903F4714CB713D89AB5F1857D73A79306C3@NA-EXMSG-C116.redmond.corp.microsoft.com> References: <372109E149E8084D8E6C7D9CFD82E06329DC62D61D@NA-EXMSG-C115.redmond.corp.microsoft.com> <002d01c840e8$222a3180$667e9480$@com> <918705E903F4714CB713D89AB5F1857D73A79306C3@NA-EXMSG-C116.redmond.corp.microsoft.com> Message-ID: <001401c841a8$cb46b8e0$61d42aa0$@com> Sorry about the Kernel stuff. I didn't realise that most of the instance methods on Object are actually in Kernel (the documentation is a bit misleading there if you don't read the top of the page carefully). Equally, I have no idea why I implemented Object.new. You are right it works fine. Perhaps I was having another problem and thought that would fix it and didn't isolate the problem. Regarding the to_int site, I think that the cases where I used it are the only ones and everywhere else use the normal protocols. I think that in those few cases they are optimizations where the other conversions in the normal protocol have already been ruled out. Sorry you are right about the YieldStep method. It should return the result of the block if it jumped. By the way, is there any difference between a block jumping with a break statement and jumping with a return statement? From jomes at microsoft.com Tue Dec 18 15:50:16 2007 From: jomes at microsoft.com (John Messerly) Date: Tue, 18 Dec 2007 12:50:16 -0800 Subject: [Ironruby-core] FW: Review of Peter Bacon Darwin's Fixnum patch In-Reply-To: <001401c841a8$cb46b8e0$61d42aa0$@com> References: <372109E149E8084D8E6C7D9CFD82E06329DC62D61D@NA-EXMSG-C115.redmond.corp.microsoft.com> <002d01c840e8$222a3180$667e9480$@com> <918705E903F4714CB713D89AB5F1857D73A79306C3@NA-EXMSG-C116.redmond.corp.microsoft.com> <001401c841a8$cb46b8e0$61d42aa0$@com> Message-ID: <918705E903F4714CB713D89AB5F1857D73A7930AF6@NA-EXMSG-C116.redmond.corp.microsoft.com> Peter Bacon Darwin: > Sorry you are right about the YieldStep method. It should return the > result of the block if it jumped. By the way, is there any difference > between a block jumping with a break statement and jumping with a > return statement? Yeah, I made that change to YieldStep & checked in. Let me know if anything didn't get merged correctly. Return & break are different, but the control flow code (RuntimeFlowControl, BlockParam) tracks that stuff. The only thing library code needs to do is: object result = _MyBlockSite.Invoke(context, block, args ...) if (block.BlockJumped(result)) { return result; } Maybe in the future we can clean that up, but that's the story for now. - John From jomes at microsoft.com Tue Dec 18 18:40:08 2007 From: jomes at microsoft.com (John Messerly) Date: Tue, 18 Dec 2007 15:40:08 -0800 Subject: [Ironruby-core] Struct builtin added, working on "super" In-Reply-To: <918705E903F4714CB713D89AB5F1857D73A7930AF6@NA-EXMSG-C116.redmond.corp.microsoft.com> References: <372109E149E8084D8E6C7D9CFD82E06329DC62D61D@NA-EXMSG-C115.redmond.corp.microsoft.com> <002d01c840e8$222a3180$667e9480$@com> <918705E903F4714CB713D89AB5F1857D73A79306C3@NA-EXMSG-C116.redmond.corp.microsoft.com> <001401c841a8$cb46b8e0$61d42aa0$@com> <918705E903F4714CB713D89AB5F1857D73A7930AF6@NA-EXMSG-C116.redmond.corp.microsoft.com> Message-ID: <918705E903F4714CB713D89AB5F1857D73A7930C56@NA-EXMSG-C116.redmond.corp.microsoft.com> I added Struct which was pushed out with the SVN update this morning. It's passing all specs expect 4, the failures are: * three because we're missing Kernel#methods, Kernel#private_method--should pass once those methods are implemented * one because of a known bug when you derive from Struct itself and call "new" on that class (deriving from classes created by Struct#new should work okay) One more built-in type down... lots to go :) FYI, I'm also working on "super" support. - John From lewistm at gmail.com Wed Dec 19 19:56:12 2007 From: lewistm at gmail.com (Terence Lewis) Date: Thu, 20 Dec 2007 02:56:12 +0200 Subject: [Ironruby-core] Inheritance question Message-ID: <2f1decf20712191656u62c92973l54813cac00b0d0a3@mail.gmail.com> Hello list, Two things: 1) I've got a question regarding inheritance and abstract base classes that I'm hoping somebody can give me some help with. I'm trying to make some socket-based stuff work based on the descriptions in the pickaxe book which states that "BasicSocket is an abstract base class for other socket classes". It also says "IPSocket is a base class for sockets using IP as their transport. TCPSocket and UDPSocket are based on this class". I've successfully implemented the class method on IPSocket, but when I wanted to make TCPSocket.addr and TCPSocket.peeraddr work (both methods should be inherited from IPSocket), I had to write this functionality directly into my TCPSocketOps class - if I put it into IPSocketOps the methods are not found. Now I have to implement UDPSocket.addr and UDPSocket.peeraddr and I don't want to duplicate the logic in the methods (besides, then it's not really inheritance is it?). To make my question clearer, I'll paste the code below. The methods in question are marked with TODO's - they sit in the TCPSocketOps class which is marked with RubyClass("TCPSocket") instead of inheriting the methods from RubyClass("IPSocket") and I'm questioning whether there is another way to do this or if that's really correct. Thanks for your time. Also, the exception I get when I move the methods to IPSocketOps is: System.MissingMethodException: undefined local variable or method `addr' for #:Ruby.Builtins.RubyClass at Ruby.Builtins.Kernel.MethodMissing(CodeContext context, Object self, BlockParam block, SymbolId name, Object[] args) in D:\Projects\IronRuby\trunk\src\IronRuby.Libraries\Builtins\Kernel.cs:line 227 using System; using System.Collections.Generic; using System.Text; using Ruby.Runtime; using System.Net.Sockets; using Ruby.Builtins; using Microsoft.Scripting; using System.Net; namespace Ruby.BuiltIns { [RubyClass("IPSocket")] public static class IPSocketOps { [RubyMethod("getaddress", RubyMethodAttributes.PublicSingleton)] public static string GetAddress(object self, MutableString hostName) { return System.Net.Dns.GetHostEntry(hostName).AddressList[0].ToString(); } } [RubyClass("TCPSocket", Inherits = typeof(Object), Extends = typeof(IPSocket))] public static class TCPSocketOps { [RubyMethod("gethostbyname", RubyMethodAttributes.PublicSingleton)] public static object GetHostByName(object self, MutableString hostName) { RubyArray result = ArrayOps.CreateArray(); System.Net.IPHostEntry hostEntry = System.Net.Dns.GetHostEntry(hostName); result.Add(hostName); result.Add(ArrayOps.CreateArray(hostEntry.Aliases.Length)); foreach (string alias in hostEntry.Aliases) { ((RubyArray)result[1]).Add(new MutableString(alias)); } result.Add((int)hostEntry.AddressList[0].AddressFamily); result.Add(new MutableString(hostEntry.AddressList[0].ToString())); return result; } [RubyMethod("new", RubyMethodAttributes.PublicSingleton)] public static TCPSocket/*!*/ CreateSocket(CodeContext/*!*/ context, object self, BlockParam/*!*/ startRoutine, [NotNull]params object[]/*!*/ args) { return new TCPSocket(args[0], args[1]); } [RubyMethod("open", RubyMethodAttributes.PublicSingleton)] public static TCPSocket/*!*/ CreateSocketAlias_Open(CodeContext/*!*/ context, object self, BlockParam/*!*/ startRoutine, [NotNull]params object[]/*!*/ args) { return CreateSocket(context, self, startRoutine, args); } // TODO: This should move into IPSocketOps - How does inheritance work in IronRuby? [RubyMethod("addr", RubyMethodAttributes.PublicInstance)] public static object GetAddress(IPSocket self) { return GetAddressFromEndPoint(self.socket.LocalEndPoint); } // TODO: This should move into IPSocketOps - How does inheritance work in IronRuby? [RubyMethod("peeraddr", RubyMethodAttributes.PublicInstance)] public static object GetPeerAddress(IPSocket self) { return GetAddressFromEndPoint(self.socket.RemoteEndPoint); } public static object GetAddressFromEndPoint(EndPoint endPoint) { RubyArray result = ArrayOps.CreateArray(); IPEndPoint ep = (IPEndPoint)endPoint; MutableString addressFamily = null; switch (ep.AddressFamily) { // Surely this already exists somewhere in System.Net? Couldn't find it though... case AddressFamily.InterNetwork: addressFamily = new MutableString("AF_INET"); break; default: throw new NotImplementedException(); } result.Add(addressFamily); result.Add(ep.Port); result.Add(new MutableString(System.Net.Dns.GetHostEntry(ep.Address).HostName)); result.Add(new MutableString(ep.Address.ToString())); return result; } } public class IPSocket { internal Socket socket; } public class TCPSocket : IPSocket { public TCPSocket(object hostname, object port) { socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); int portNumber = 0; if (port is int) { portNumber = (int)port; } else if (port is MutableString) { switch ((MutableString)port) { case "ftp": portNumber = 21; break; case "http": portNumber = 80; break; default: throw new NotImplementedException(); } } socket.Connect((MutableString)hostname, portNumber); } } } From lewistm at gmail.com Wed Dec 19 20:00:18 2007 From: lewistm at gmail.com (Terence Lewis) Date: Thu, 20 Dec 2007 03:00:18 +0200 Subject: [Ironruby-core] Inheritance question In-Reply-To: <2f1decf20712191656u62c92973l54813cac00b0d0a3@mail.gmail.com> References: <2f1decf20712191656u62c92973l54813cac00b0d0a3@mail.gmail.com> Message-ID: <2f1decf20712191700l5fd63a7bq3a1d016c9edb0ea9@mail.gmail.com> Apologies - I have an itchy send finger. The other issue is that I think the file CalcOps.cs is in the repository, but not included in the project - so the code refuses to build cleanly on the latest revision. I worked around this by manually adding the file to the correct project in visual studio. Thanks for your time Terence On Dec 20, 2007 2:56 AM, Terence Lewis wrote: > Hello list, > > Two things: > > 1) ... > From jflam at microsoft.com Wed Dec 19 20:05:34 2007 From: jflam at microsoft.com (John Lam (DLR)) Date: Wed, 19 Dec 2007 17:05:34 -0800 Subject: [Ironruby-core] Inheritance question In-Reply-To: <2f1decf20712191700l5fd63a7bq3a1d016c9edb0ea9@mail.gmail.com> References: <2f1decf20712191656u62c92973l54813cac00b0d0a3@mail.gmail.com> <2f1decf20712191700l5fd63a7bq3a1d016c9edb0ea9@mail.gmail.com> Message-ID: <372109E149E8084D8E6C7D9CFD82E06329DC62E3A4@NA-EXMSG-C115.redmond.corp.microsoft.com> Terence Lewis: > > Apologies - I have an itchy send finger. The other issue is that I > think the file CalcOps.cs is in the repository, but not included in > the project - so the code refuses to build cleanly on the latest > revision. I worked around this by manually adding the file to the > correct project in visual studio. I just removed this file from SVN. It was an artifact of a demo that I did at RubyConf ... -John From bacondarwin at googlemail.com Thu Dec 20 11:30:35 2007 From: bacondarwin at googlemail.com (Peter Bacon Darwin) Date: Thu, 20 Dec 2007 16:30:35 -0000 Subject: [Ironruby-core] Inheritance question In-Reply-To: <2f1decf20712191656u62c92973l54813cac00b0d0a3@mail.gmail.com> References: <2f1decf20712191656u62c92973l54813cac00b0d0a3@mail.gmail.com> Message-ID: <000301c84325$a6a94060$f3fbc120$@com> I think you are getting too carried away with the various conventions around extending .NET types for use by the DLR. If you are simply wanting to wrap the underlying System.Net.Sockets.Socket class (rather than extend it) then you don't need to have both IPSocket and IPSocketOps classes and so on. It is enough to have an abstract non-static class IPSocket and a concrete class TCPSocket, which derives directly from IPSocket. Everything then works. See the code below. using System; using System.Collections.Generic; using System.Text; using Ruby.Runtime; using System.Net.Sockets; using Ruby.Builtins; using Microsoft.Scripting; using System.Net; namespace Ruby.BuiltIns { [RubyClass("IPSocket")] public abstract class IPSocket { internal Socket socket; [RubyMethod("getaddress", RubyMethodAttributes.PublicSingleton)] public static string GetAddress(object self, MutableString hostName) { return System.Net.Dns.GetHostEntry(hostName).AddressList[0].ToString(); } [RubyMethod("addr", RubyMethodAttributes.PublicInstance)] public static object GetAddress(IPSocket self) { return GetAddressFromEndPoint(self.socket.LocalEndPoint); } [RubyMethod("peeraddr", RubyMethodAttributes.PublicInstance)] public static object GetPeerAddress(IPSocket self) { return GetAddressFromEndPoint(self.socket.RemoteEndPoint); } public static object GetAddressFromEndPoint(EndPoint endPoint) { RubyArray result = ArrayOps.CreateArray(); IPEndPoint ep = (IPEndPoint)endPoint; MutableString addressFamily = null; switch (ep.AddressFamily) { // Surely this already exists somewhere in System.Net? Couldn't find it though... case AddressFamily.InterNetwork: addressFamily = new MutableString("AF_INET"); break; default: throw new NotImplementedException(); } result.Add(addressFamily); result.Add(ep.Port); result.Add(new MutableString(System.Net.Dns.GetHostEntry(ep.Address).HostName)); result.Add(new MutableString(ep.Address.ToString())); return result; } } [RubyClass("TCPSocket")] public class TCPSocket : IPSocket { [RubyMethod("gethostbyname", RubyMethodAttributes.PublicSingleton)] public static object GetHostByName(object self, MutableString hostName) { RubyArray result = ArrayOps.CreateArray(); System.Net.IPHostEntry hostEntry = System.Net.Dns.GetHostEntry(hostName); result.Add(hostName); result.Add(ArrayOps.CreateArray(hostEntry.Aliases.Length)); foreach (string alias in hostEntry.Aliases) { ((RubyArray)result[1]).Add(new MutableString(alias)); } result.Add((int)hostEntry.AddressList[0].AddressFamily); result.Add(new MutableString(hostEntry.AddressList[0].ToString())); return result; } [RubyMethod("new", RubyMethodAttributes.PublicSingleton)] public static TCPSocket/*!*/ CreateSocket(CodeContext/*!*/ context, object self, BlockParam/*!*/ startRoutine, [NotNull]params object[]/*!*/ args) { return new TCPSocket(args[0], args[1]); } [RubyMethod("open", RubyMethodAttributes.PublicSingleton)] public static TCPSocket/*!*/ CreateSocketAlias_Open(CodeContext/*!*/ context, object self, BlockParam/*!*/ startRoutine, [NotNull]params object[]/*!*/ args) { return CreateSocket(context, self, startRoutine, args); } public TCPSocket(object hostname, object port) { socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); int portNumber = 0; if (port is int) { portNumber = (int)port; } else if (port is MutableString) { switch ((MutableString)port) { case "ftp": portNumber = 21; break; case "http": portNumber = 80; break; default: throw new NotImplementedException(); } } socket.Connect((MutableString)hostname, portNumber); } } } From bacondarwin at googlemail.com Thu Dec 20 11:38:26 2007 From: bacondarwin at googlemail.com (Peter Bacon Darwin) Date: Thu, 20 Dec 2007 16:38:26 -0000 Subject: [Ironruby-core] Inheritance question In-Reply-To: <2f1decf20712191656u62c92973l54813cac00b0d0a3@mail.gmail.com> References: <2f1decf20712191656u62c92973l54813cac00b0d0a3@mail.gmail.com> Message-ID: <000401c84326$bfe95fa0$3fbc1ee0$@com> Alternatively, you may prefer not to wrap the .NET type and to extend System.Net.Sockets.Socket into the DLR directly. This is inline with the extension of other .NET classes such as Int32 to Fixnum and MutableString to MutableString. The following code demonstrates how you could do this... using System; using System.Collections.Generic; using System.Text; using Ruby.Runtime; using System.Net.Sockets; using Ruby.Builtins; using Microsoft.Scripting; using System.Net; namespace Ruby.BuiltIns { [RubyClass("IPSocket", Extends=typeof(Socket))] public static class IPSocketOps { [RubyMethod("getaddress", RubyMethodAttributes.PublicSingleton)] public static string GetAddress(RubyClass klass, MutableString hostName) { return System.Net.Dns.GetHostEntry(hostName).AddressList[0].ToString(); } [RubyMethod("addr", RubyMethodAttributes.PublicInstance)] public static object GetAddress(Socket self) { return GetAddressFromEndPoint(self.LocalEndPoint); } [RubyMethod("peeraddr", RubyMethodAttributes.PublicInstance)] public static object GetPeerAddress(Socket self) { return GetAddressFromEndPoint(self.RemoteEndPoint); } public static object GetAddressFromEndPoint(EndPoint endPoint) { RubyArray result = ArrayOps.CreateArray(); IPEndPoint ep = (IPEndPoint)endPoint; MutableString addressFamily = null; switch (ep.AddressFamily) { // Surely this already exists somewhere in System.Net? Couldn't find it though... case AddressFamily.InterNetwork: addressFamily = new MutableString("AF_INET"); break; default: throw new NotImplementedException(); } result.Add(addressFamily); result.Add(ep.Port); result.Add(new MutableString(System.Net.Dns.GetHostEntry(ep.Address).HostName)); result.Add(new MutableString(ep.Address.ToString())); return result; } } [RubyClass("TCPSocket", Inherits=typeof(IPSocketOps))] public static class TCPSocket : Object{ [RubyMethod("gethostbyname", RubyMethodAttributes.PublicSingleton)] public static object GetHostByName(object self, MutableString hostName) { RubyArray result = ArrayOps.CreateArray(); System.Net.IPHostEntry hostEntry = System.Net.Dns.GetHostEntry(hostName); result.Add(hostName); result.Add(ArrayOps.CreateArray(hostEntry.Aliases.Length)); foreach (string alias in hostEntry.Aliases) { ((RubyArray)result[1]).Add(new MutableString(alias)); } result.Add((int)hostEntry.AddressList[0].AddressFamily); result.Add(new MutableString(hostEntry.AddressList[0].ToString())); return result; } [RubyMethod("new", RubyMethodAttributes.PublicSingleton)] public static Socket/*!*/ CreateSocket(CodeContext/*!*/ context, object self, BlockParam/*!*/ startRoutine, [NotNull]params object[]/*!*/ args) { object hostname = args[0]; object port = args[1]; Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); int portNumber = 0; if (port is int) { portNumber = (int)port; } else if (port is MutableString) { switch ((MutableString)port) { case "ftp": portNumber = 21; break; case "http": portNumber = 80; break; default: throw new NotImplementedException(); } } socket.Connect((MutableString)hostname, portNumber); return socket; } [RubyMethod("open", RubyMethodAttributes.PublicSingleton)] public static Socket/*!*/ CreateSocketAlias_Open(CodeContext/*!*/ context, object self, BlockParam/*!*/ startRoutine, [NotNull]params object[]/*!*/ args) { return CreateSocket(context, self, startRoutine, args); } } } From bacondarwin at googlemail.com Fri Dec 21 15:53:09 2007 From: bacondarwin at googlemail.com (Peter Bacon Darwin) Date: Fri, 21 Dec 2007 20:53:09 -0000 Subject: [Ironruby-core] Is the Fixnum size difference a problem? Message-ID: <000001c84413$8083d550$818b7ff0$@com> The size of Fixnum in a standard C implementation of Ruby is a machine word minus one bit. I.E. For most 32 bit machines that is 31 bits. (The implementation uses the bottom bit as a flag). Therefore the largest value that you can hold in their Fixnum is 0x3fffffff. IronRuby uses System.Int32 to hold its Fixnum values and doesn't have a flag bit so the size of Fixnum in IronRuby is 32 bits. Therefore the largest value you can hold is 0x7fffffff. This shouldn't run into any problems since the transition between Fixnum and Bignum is supposedly transparent; you don't really care (although you may know) what class is representing the value you are working with. Unfortunately, I recently noticed that the div method has different semantics depending upon whether you are a Fixnum or Bignum. some_fixnum.div(0.0) => raises FloatDomainError some_bignum.div(0.0) => Infinity IronRuby has the same semantics, except that of course what is a Bignum for CRuby is not a Bignum for IronRuby. In CRuby: 0x40000000.div(0.0) => Infinity In IronRuby: 0x40000000.div(0.0) => raises FloatDomainError Now clearly this is a problem with the fundamental implementation of Fixnum/Bignum but Rubinius seems to follow suit and I assume JRuby too (although I haven't checked). What are your thoughts on dealing with this issue? Should we brush it under the carpet and hope that Ruby 2.0 will fix it or what? Should we force IronRuby's Fixnum to be 31 bits? Any ideas most welcome. Pete -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/ironruby-core/attachments/20071221/e9520750/attachment.html From jomes at microsoft.com Fri Dec 21 16:45:02 2007 From: jomes at microsoft.com (John Messerly) Date: Fri, 21 Dec 2007 13:45:02 -0800 Subject: [Ironruby-core] Is the Fixnum size difference a problem? In-Reply-To: <000001c84413$8083d550$818b7ff0$@com> References: <000001c84413$8083d550$818b7ff0$@com> Message-ID: <918705E903F4714CB713D89AB5F1857D73A7BF48BE@NA-EXMSG-C116.redmond.corp.microsoft.com> Peter Bacon Darwin: > IronRuby has the same semantics, except that of course what is a > Bignum for CRuby is not a Bignum for IronRuby. > > In CRuby: > > 0x40000000.div(0.0) => Infinity > > In IronRuby: > > 0x40000000.div(0.0) => raises FloatDomainError > > Now clearly this is a problem with the fundamental implementation of > Fixnum/Bignum but Rubinius seems to follow suit and I assume JRuby too > (although I haven't checked). > > What are your thoughts on dealing with this issue? Should we brush it > under the carpet and hope that Ruby 2.0 will fix it or what? Should > we force IronRuby's Fixnum to be 31 bits? I think we can keep Fixnums at 32 bits, and fix div to throw. Just tried in JRuby: irb(main):001:0> 0x4000_0000_0000_0000.class => Fixnum irb(main):002:0> 0x4000_0000.div(0.0) FloatDomainError: Infinity They actually have 64bit Fixnums... wow :) - John From charles.nutter at sun.com Fri Dec 21 17:07:41 2007 From: charles.nutter at sun.com (Charles Oliver Nutter) Date: Fri, 21 Dec 2007 16:07:41 -0600 Subject: [Ironruby-core] Is the Fixnum size difference a problem? In-Reply-To: <918705E903F4714CB713D89AB5F1857D73A7BF48BE@NA-EXMSG-C116.redmond.corp.microsoft.com> References: <000001c84413$8083d550$818b7ff0$@com> <918705E903F4714CB713D89AB5F1857D73A7BF48BE@NA-EXMSG-C116.redmond.corp.microsoft.com> Message-ID: <476C392D.1060201@sun.com> John Messerly wrote: > I think we can keep Fixnums at 32 bits, and fix div to throw. Just tried in JRuby: > > irb(main):001:0> 0x4000_0000_0000_0000.class > => Fixnum > irb(main):002:0> 0x4000_0000.div(0.0) > FloatDomainError: Infinity > > They actually have 64bit Fixnums... wow :) Yeah, we realized very recently that at some point we switches Fixnum to 64 bits, and now we don't care to switch it back. So we're using a Java long primitive internally to represent it, and I believe we're stripping off the upper bit or two. This issue actually came up today while I was fixing some spec failures in JRuby. The specs do check that Fixnum is four bytes...but I talked with Rubinius folks and they agree it should be made flexible enough for other size Fixnums, since even Ruby's own documentation says Fixnum may be different sizes on different hardware (and perhaps we may have used a 64-bit machine to run Ruby at some point, leading to JRuby's 64-bit Fixnums). I don't think the precision of Fixnum is a specifiable detail, especially since there's no loss of precision from a rollover into Bignum...whenever that happens. - Charlie From geraldbauer2007 at gmail.com Sun Dec 23 21:58:44 2007 From: geraldbauer2007 at gmail.com (Gerald Bauer) Date: Sun, 23 Dec 2007 18:58:44 -0800 Subject: [Ironruby-core] [ANN] Join us for Vancouver's 1st (Iron)RubyCamp @ WorkSpace on January 26th, 2008 Message-ID: <7e7cb8940712231858v2ded10f4y9680169a481d71e3@mail.gmail.com> Hello IronRubyists, You are invited to (Iron)RubyCamp 2008 in Vancouver on Saturday, January 26th. RubyCamp is an one-day gathering for (Iron)Rubyists and Railers. When and Where: WorkSpace in downtown Vancouver, B.C., Canada January 26th, 2008 from 9:00 to 5:00 Who Should Come: Anyone who's interested in Ruby and Rails, whether you're just interested in learning what this Ruby thing is all about or you know Ruby inside out. The Conference Track: A conference-style track with "classic" talks on Ruby or Rails topics. We're looking for a few more speakers including talks about IronRuby, so see http://rubycamp.wordpress.com/about/#talks if you're interested in giving a talk. The Hackathon Track: An informal un-conference track focusing on hacking some Ruby code, showing off a cool feature you just added to your Rails application or demonstrating a new addition to Rails 2.0. If you're interested in working on some code or showing off something, get started by promoting your ideas and getting some buzz going: http://rubycamp.wordpress.com/about/#hackathon . A Weekend of Ruby: There are two more reasons to come to Vancouver for those of you who are out of town. On the Friday before RubyCamp, Rails Advance is giving a one day intermediate Ruby and Rails workshop (incl. Facebook and Mobile Web) (http://railsadvance.com/workshop). On the Sunday after RubyCamp, Peter Armstrong is giving a one day workshop on using Flex and Rails (http://www.flexiblerails.com/workshops). About Vancouver: Vancouver is located in Beautiful British Columbia on Canada's Pacific West Coast. While you're in the 2010 Winter Olympics City take advantage of the great snowboarding and skiing in nearby Whistler/Blackcomp or Cypress Mountain. For more information, see http://rubycamp.wordpress.com See you all at RubyCamp in Vancouver. Cheers. _______________________________________________________ RailsAdvance Workshops - http://railsadvance.com Gerald Bauer's Blog - http://geraldbauer.wordpress.com From myreply at gmail.com Tue Dec 25 22:57:58 2007 From: myreply at gmail.com (myreply) Date: Wed, 26 Dec 2007 09:27:58 +0530 Subject: [Ironruby-core] IronRuby on rails - A comment posted on Rob Connery's Blog. Message-ID: Hi, I just found this comment on " Rob Conery's " Blog about SubSonic and the future of MVC . I am pasting as it is. ----------------------------------------------------------------------------------------------------------------------- Hi Rob, Very good informative blog indeed. I am curious to know one step ahead, since after few months DLR would be the preferred way for other dynamic languages to enter .net world. As per John Lam, the person behind IronRuby? He says?" My mission would not be complete, if i cannot run Ruby on rails with Iron Ruby ". I want to make Ruby as Class 1 language for DLR. Ok great move by MS for porting all other good languages to DLR. But the question that arises is? " How will IronRuby run Ruby on rails on DLR without Active Record?.? (1) Will they develop new Active Record type tool that runs only on DLR. (2) Will they utilize SubSonic in a different way, that runs as totally Active Record Solution for DLR. (3) Ruby On Rails is also an MVC? Will IronRuby create a different Ruby on rails MVC for DLR. that supports SubSonic? OK? it sounds to early now? But worth thinking whats going to happen in future. SilverLight 2.0 is based on DLR and arrives almost in March 2008, so my question is only 3 months ahead not very far? Hope i am able to clarify few things. Thanks ------------------------------------- The answer from Rob is here... @Paraag: Rails is simply a stack that runs on Rubyw.exe - in other words a bunch of scripted commands that live in a directory. The thing here is that the Rails app is handled (as of now) by Rubyw.exe (through CGI). The thing Jon is making is (essentially) a replacement for Rubyw.exe - so in essence a Rails app should be "droppable" onto the DLR. Now I've never played with IronRuby - this is just what I'm guessing at. If I'm wrong - someone out there lemme know cause my whole thought here is you can still do Rails - just execute it (5 times faster) using the DLR. ------------------------ Hi John, Per haps you can focus more on this. Here's the original thread... http://blog.wekeroad.com/2007/12/14/aspnet-mvc-choosing-your-data-access-method/#comments Thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/ironruby-core/attachments/20071226/a325a18a/attachment.html From lists at ruby-forum.com Thu Dec 27 20:38:56 2007 From: lists at ruby-forum.com (Shin guey Wong) Date: Fri, 28 Dec 2007 02:38:56 +0100 Subject: [Ironruby-core] IronRuby on rails - A comment posted on Rob Connery's Bl In-Reply-To: References: Message-ID: <0c01ee1d58364f8e124270f93353c7b0@ruby-forum.com> myreply wrote: > Hi, > > I just found this comment on " Rob Conery's " Blog about SubSonic and > the > future of MVC . I am pasting as it is. > > SubSonic is really cool. I had watch the screen cast and it is really interesting. Rob done a good job on integrating the SubSonic into VS IDE. It is a rail like development but with c# and subsonic on VS and ASP. -- Posted via http://www.ruby-forum.com/. From charles.nutter at sun.com Thu Dec 27 21:32:21 2007 From: charles.nutter at sun.com (Charles Oliver Nutter) Date: Thu, 27 Dec 2007 20:32:21 -0600 Subject: [Ironruby-core] IronRuby on rails - A comment posted on Rob Connery's Blog. In-Reply-To: References: Message-ID: <47746035.7040106@sun.com> myreply wrote: > But the question that arises is? " How will IronRuby run Ruby on rails > on DLR without Active Record?.? Why wouldn't you have ActiveRecord? ActiveRecord is 100% Ruby, and even the adapters for specific databases usually have a pure Ruby version. Beyond that, it wouldn't be hard to wire them into .NET's usual database connectors. - Charlie From bacondarwin at googlemail.com Fri Dec 28 16:16:48 2007 From: bacondarwin at googlemail.com (Peter Bacon Darwin) Date: Fri, 28 Dec 2007 21:16:48 -0000 Subject: [Ironruby-core] $0 global variable Message-ID: <000001c84996$f60a95b0$e21fc110$@com> I would really like to be able to do this: if __FILE__ == $0 require File.dirname(__FILE__) + '/../../Util/simple_test.rb' end But, since $0 currently always returns nil, I can't. Any chance you could squeeze it into the next SVN revision? Cheers, Pete -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/ironruby-core/attachments/20071228/3fe852ad/attachment-0001.html From lewistm at gmail.com Sat Dec 29 08:35:22 2007 From: lewistm at gmail.com (Terence Lewis) Date: Sat, 29 Dec 2007 15:35:22 +0200 Subject: [Ironruby-core] Patch submission - sockets Message-ID: <2f1decf20712290535t5a46ab6ch913e587fe16815ba@mail.gmail.com> Hello list, Please find attached the beginnings of a sockets implementation for IronRuby. Included in this patch is the following: - Class BasicSocket - Class IPSocket - Class TCPSocket - Class TCPServer These classes aren't completely fleshed out, but they are functional to the point where I could create a very primitive web server using TCPServer that returns a dynamic HTML page which displays the current time, and read that page using either TCPSocket or my web browser. A couple of points: 1) I haven't yet signed the contributor agreement. I did email the address listed on the wiki, but I haven't heard back from it yet. I presume this is because of the holiday season. 2) This is my first contribution to an open source project, and I'm under no illusions as to the many flaws in this code. Any comments, criticism or suggestion is welcome, and I assume that the code will be reviewed before being accepted. 3) There are no automated tests with this code :(. I'm more than happy to write tests, but I need some help and guidance about what tests to write (or use if there are existing tests for this functionality in JRuby or Rubinius). It seems to me that testing sockets is quite hard, because of the need to make sure the tests run on different machines and networks. Thanks for your time Terence -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: Socket.cs Url: http://rubyforge.org/pipermail/ironruby-core/attachments/20071229/ace5a803/attachment.pl From sanxiyn at gmail.com Sat Dec 29 10:57:36 2007 From: sanxiyn at gmail.com (Sanghyeon Seo) Date: Sun, 30 Dec 2007 00:57:36 +0900 Subject: [Ironruby-core] Patch submission - sockets In-Reply-To: <2f1decf20712290535t5a46ab6ch913e587fe16815ba@mail.gmail.com> References: <2f1decf20712290535t5a46ab6ch913e587fe16815ba@mail.gmail.com> Message-ID: <5b0248170712290757x3d141a16xc3042708ee0a5d8d@mail.gmail.com> 2007/12/29, Terence Lewis : > This is my first contribution to an open source project, and I'm > under no illusions as to the many flaws in this code. Any comments, > criticism or suggestion is welcome, and I assume that the code will be > reviewed before being accepted. Hi, nice job. 1. Mixing tabs and spaces for indentation is a bad practice. 2. I don't think recvfrom is correct. It calls Socket.Receive, but it should call Socket.ReceiveFrom. 3. IPAddress.Any reads better than IPAddress(0). 4. Not sure about DNS stuffs. -- Seo Sanghyeon