We''re thinking now that we''re going to go with the mangled version of the name instead of the originally cased-version. "Dispose" just doesn''t look Rubyish enough. Any objections? From: Curt Hagenlocher Sent: Monday, September 08, 2008 9:22 PM To: ''ironruby-core at rubyforge.org'' Subject: Overriding CLS Virtuals I''ve committed some changes to IronRuby (in SVN revision 141) that let you implement CLS interfaces and override virtual methods on CLS base types. Interfaces work like Ruby modules, so to make your class implement IDisposable you could say require ''mscorlib'' class Disposable include System.IDisposable def Dispose # Do something end end You can also override virtual properties. A class or interface that has the C# declaration "string Value { get; set; }" is overridden from IronRuby with methods named "Value" for the getter and "Value=" for the setter. Note that you need to use the same casing as the CLS definition for both methods and properties. We''re just getting started with better .NET interop support and don''t have very much test coverage yet - but this should let you get going on some more sophisticated interop scenarios than were previously possible. -- Curt Hagenlocher curth at microsoft.com -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/ironruby-core/attachments/20081024/5864501d/attachment.html>
On Fri, Oct 24, 2008 at 7:54 PM, Curt Hagenlocher <curth at microsoft.com> wrote:> We''re thinking now that we''re going to go with the mangled version of the > name instead of the originally cased-version. "Dispose" just doesn''t look > Rubyish enough. Any objections?My opinion does not count for much but I love Ruby openness and hate the naming conventions. I much prefer camel case and .NET guidelines for naming than underscore and lowercase hell. I am just getting started with Ruby and have no intention of following the naming conventions if I can avoid it. IronRuby and .NET are my platform of choice for the future, even in its immature state.
Do it. :) On Fri, Oct 24, 2008 at 8:54 PM, Curt Hagenlocher <curth at microsoft.com>wrote:> We''re thinking now that we''re going to go with the mangled version of the > name instead of the originally cased-version. "Dispose" just doesn''t look > Rubyish enough. Any objections? > > > > *From:* Curt Hagenlocher > *Sent:* Monday, September 08, 2008 9:22 PM > *To:* ''ironruby-core at rubyforge.org'' > *Subject:* Overriding CLS Virtuals > > > > I''ve committed some changes to IronRuby (in SVN revision 141) that let you > implement CLS interfaces and override virtual methods on CLS base types. > Interfaces work like Ruby modules, so to make your class implement > IDisposable you could say > > > > require ''mscorlib'' > > class Disposable > > include System.IDisposable > > def Dispose > > # Do something > > end > > end > > > > You can also override virtual properties. A class or interface that has > the C# declaration "string Value { get; set; }" is overridden from IronRuby > with methods named "Value" for the getter and "Value=" for the setter. > > > > Note that you need to use the same casing as the CLS definition for both > methods and properties. > > > > We''re just getting started with better .NET interop support and don''t have > very much test coverage yet ? but this should let you get going on some more > sophisticated interop scenarios than were previously possible. > > > > -- > > Curt Hagenlocher > > curth at microsoft.com > > _______________________________________________ > Ironruby-core mailing list > Ironruby-core at rubyforge.org > http://rubyforge.org/mailman/listinfo/ironruby-core > >-- Michael Letterle [Polymath Prokrammer] http://blog.prokrams.com -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/ironruby-core/attachments/20081024/6884e613/attachment.html>
Hey that''s one of the best parts of Ruby, aside from the siglets and capitalization rules for constants, you _can_ do whatever naming you want. Glad to haave your support :) JD -----Original Message----- From: Ted Milker <tmilker at gmail.com> Sent: October 24, 2008 6:11 PM To: ironruby-core at rubyforge.org <ironruby-core at rubyforge.org> Subject: Re: [Ironruby-core] Overriding CLS Virtuals On Fri, Oct 24, 2008 at 7:54 PM, Curt Hagenlocher <curth at microsoft.com> wrote:> We''re thinking now that we''re going to go with the mangled version of the > name instead of the originally cased-version. "Dispose" just doesn''t look > Rubyish enough. Any objections?My opinion does not count for much but I love Ruby openness and hate the naming conventions. I much prefer camel case and .NET guidelines for naming than underscore and lowercase hell. I am just getting started with Ruby and have no intention of following the naming conventions if I can avoid it. IronRuby and .NET are my platform of choice for the future, even in its immature state. _______________________________________________ Ironruby-core mailing list Ironruby-core at rubyforge.org http://rubyforge.org/mailman/listinfo/ironruby-core
On Fri, Oct 24, 2008 at 6:54 PM, Curt Hagenlocher <curth at microsoft.com>wrote:> We''re thinking now that we''re going to go with the mangled version of the > name instead of the originally cased-version. "Dispose" just doesn''t look > Rubyish enough. Any objections? >No objections. I''d prefer def dispose; end over def Dispose; end. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/ironruby-core/attachments/20081024/ffaa8fd8/attachment.html>
On Fri, Oct 24, 2008 at 7:11 PM, Ted Milker <tmilker at gmail.com> wrote:> > I much prefer camel case and .NET guidelines for naming than underscore and > lowercase hell.You''d like it better if you''d call it "snake case". :) -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/ironruby-core/attachments/20081024/39e43619/attachment.html>
I used to think this kind of thing too. Each language (or large-subset-of-language) has it''s own conventions. Examples: gnu/posix C: lower_underscore_case Microsoft C (eg the win32 api): UpperCamelCase Java: lowerCamelCase Javascript: lowerCamelCase .NET: UpperCamelCase (except local variables which seem to be lowerCamelCase) ruby/python: lower_underscore_case While none of the languages will stop you from using any conventions you like, it''s MUCH easier to learn to put your ego aside, and go with the conventions. The simple fact is, you''re going to be reading loads of sourcecode written by others in the form of examples and so forth, and if you get annoyed every time you see stuff you ''hate'' - well you''re going to be having a pretty unhappy time. On 25/10/2008, at 2:11 PM, Ted Milker wrote:> On Fri, Oct 24, 2008 at 7:54 PM, Curt Hagenlocher > <curth at microsoft.com> wrote: >> We''re thinking now that we''re going to go with the mangled version >> of the >> name instead of the originally cased-version. "Dispose" just >> doesn''t look >> Rubyish enough. Any objections? > > My opinion does not count for much but I love Ruby openness and hate > the naming conventions. I much prefer camel case and .NET guidelines > for naming than underscore and lowercase hell. I am just getting > started with Ruby and have no intention of following the naming > conventions if I can avoid it. IronRuby and .NET are my platform of > choice for the future, even in its immature state. > _______________________________________________ > Ironruby-core mailing list > Ironruby-core at rubyforge.org > http://rubyforge.org/mailman/listinfo/ironruby-core
On Sat, Oct 25, 2008 at 6:59 PM, Orion Edwards <orion.edwards at open2view.com> wrote:> While none of the languages will stop you from using any conventions you > like, it''s MUCH easier to learn to put your ego aside, and go with the > conventions.I agree, however, the DLR adds a twist to the formula.> The simple fact is, you''re going to be reading loads of sourcecode written > by others in the form of examples and so forth, and if you get annoyed every > time you see stuff you ''hate'' - well you''re going to be having a pretty > unhappy time.I do not get annoyed if I am reading or programming in a single language. I do like to keep things simple though. If I am working in .NET, I am going to keep a single, consistent style convention for my source code. I am not going to maintain two different conventions just because I am using Ruby in half of my app and C# in the other. Even if it were pure Ruby in IronRuby, I would use .NET guidelines because I am almost certain to be using the .NET libraries in IronRuby. In this case and in my opinion, the framework determines the convention, not the languages used. One of the main reasons why I am interested in IronRuby is because it will give me access to WPF. GUIs with Ruby in Windows, I have learned, is a pretty painful and overall annoying experience compared to C# and WPF. I do have a particular dislike for the underscore key because of its placement on the keyboard as well.
Let''s say that w is a WPF window. That is, w = System::Windows::Window.new Then you can currently get the actual height of the window by saying either w.ActualHeight -or- w.actual_height. This is something that we don''t intend to change. The nature of a dynamic call site is such that the method lookup is deferred until the point this code is reached, and then we''re free to bind the actual call target using whatever semantics we please. We don''t even have to pay any real overhead for this ability, because we cache the result of the lookups after they were made the first time and don''t have to perform them again. (Window *is* after all, a *static* type. :) However, virtual calls from a C# application back into IronRuby are a different matter, due Ruby''s dynamic nature. Here there is both a performance cost and a semantic cost for performing multiple lookups. The performance cost results from the fact that we have to check for two different symbol names on every CLS call to this method before we can identify that we need to delegate to the base class implementation. (To be fair, this, too could be cached, albeit with slightly greater difficulty.) The semantic cost is based in the confusion resulting when methods with both names are defined on the class. Should we call method "dispose" or method "Dispose"? or both? Finally, as you''re probably aware by now, capitalization in Ruby is not simply a matter of convention. In many cases, the parser actually treats identifiers which start with a capital letter differently than it does identifiers that start lower case. Now it turns out that method names are one of the places where Ruby doesn''t draw this distinction, but I''d guess that many Ruby programmers look at any identifier starting with a capital letter and think "that''s a constant". -----Original Message----- From: ironruby-core-bounces at rubyforge.org [mailto:ironruby-core-bounces at rubyforge.org] On Behalf Of Ted Milker Sent: Saturday, October 25, 2008 9:35 PM To: ironruby-core at rubyforge.org Subject: Re: [Ironruby-core] Overriding CLS Virtuals On Sat, Oct 25, 2008 at 6:59 PM, Orion Edwards <orion.edwards at open2view.com> wrote:> While none of the languages will stop you from using any conventions you > like, it''s MUCH easier to learn to put your ego aside, and go with the > conventions.I agree, however, the DLR adds a twist to the formula.> The simple fact is, you''re going to be reading loads of sourcecode written > by others in the form of examples and so forth, and if you get annoyed every > time you see stuff you ''hate'' - well you''re going to be having a pretty > unhappy time.I do not get annoyed if I am reading or programming in a single language. I do like to keep things simple though. If I am working in .NET, I am going to keep a single, consistent style convention for my source code. I am not going to maintain two different conventions just because I am using Ruby in half of my app and C# in the other. Even if it were pure Ruby in IronRuby, I would use .NET guidelines because I am almost certain to be using the .NET libraries in IronRuby. In this case and in my opinion, the framework determines the convention, not the languages used. One of the main reasons why I am interested in IronRuby is because it will give me access to WPF. GUIs with Ruby in Windows, I have learned, is a pretty painful and overall annoying experience compared to C# and WPF. I do have a particular dislike for the underscore key because of its placement on the keyboard as well. _______________________________________________ Ironruby-core mailing list Ironruby-core at rubyforge.org http://rubyforge.org/mailman/listinfo/ironruby-core
On Sun, Oct 26, 2008 at 12:20 AM, Curt Hagenlocher <curth at microsoft.com> wrote:> > However, virtual calls from a C# application back into IronRuby are a different matter, due Ruby''s dynamic nature. Here there is both a performance cost and a semantic cost for performing multiple lookups. The performance cost results from the fact that we have to check for two different symbol names on every CLS call to this method before we can identify that we need to delegate to the base class implementation. (To be fair, this, too could be cached, albeit with slightly greater difficulty.) The semantic cost is based in the confusion resulting when methods with both names are defined on the class. Should we call method "dispose" or method "Dispose"? or both?This is a tough one, glad I do not have to make the call. Pitfalls and trouble every way I try to think of it and type a response. :) My gut tells me that capitalization matters, regardless of The Ruby Way, when it comes to .NET. If you want to write a new Dispose, def Dispose.> Finally, as you''re probably aware by now, capitalization in Ruby is not simply a matter of convention. In many cases, the parser actually treats identifiers which start with a capital letter differently than it does identifiers that start lower case. Now it turns out that method names are one of the places where Ruby doesn''t draw this distinction, but I''d guess that many Ruby programmers look at any identifier starting with a capital letter and think "that''s a constant".But given the following: def Foo "Bar" end Foo() what Ruby programmer would look at Foo and still think it is a constant? Of course, if I would have made it lowercase, the parentheses would not be necessary. My point is that the parentheses tell the reader that it is not a constant, but a method. Is there a situation where Foo could appear legally, as defined above, without parentheses and be confused for a constant?
On Sat, Oct 25, 2008 at 11:20 PM, Curt Hagenlocher <curth at microsoft.com>wrote:> Now it turns out that method names are one of the places where Ruby doesn''t > draw this distinction, but I''d guess that many Ruby programmers look at any > identifier starting with a capital letter and think "that''s a constant".Agreed. That''s what I think when I see that. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/ironruby-core/attachments/20081026/15cd5fc3/attachment-0001.html>
The parenthesis do give an important clue, and luckily they are required for calling a method with a constant identifier. As far as idioms and conventions go, I don''t know how much of an official convention (as much as a Ruby convention is official) there is, but the few cases of capitalized methods I''ve seen do one of two things, cast to the name of the method (Kernel.Float for example) or they return a class. An example of the second is the R() method in _why''s Camping framework, which returns a class for controllers. It''s used in class definitions in this case: class Foo < R(''/'') end is a controller at the route / (root of the website). So since I''m used to that, I prefer seeing IDisposable use def dispose in my Ruby classes. JD ________________________________________ From: ironruby-core-bounces at rubyforge.org [ironruby-core-bounces at rubyforge.org] On Behalf Of Ted Milker [tmilker at gmail.com] Sent: Saturday, October 25, 2008 11:12 PM To: ironruby-core at rubyforge.org Subject: Re: [Ironruby-core] Overriding CLS Virtuals On Sun, Oct 26, 2008 at 12:20 AM, Curt Hagenlocher <curth at microsoft.com> wrote:> > However, virtual calls from a C# application back into IronRuby are a different matter, due Ruby''s dynamic nature. Here there is both a performance cost and a semantic cost for performing multiple lookups. The performance cost results from the fact that we have to check for two different symbol names on every CLS call to this method before we can identify that we need to delegate to the base class implementation. (To be fair, this, too could be cached, albeit with slightly greater difficulty.) The semantic cost is based in the confusion resulting when methods with both names are defined on the class. Should we call method "dispose" or method "Dispose"? or both?This is a tough one, glad I do not have to make the call. Pitfalls and trouble every way I try to think of it and type a response. :) My gut tells me that capitalization matters, regardless of The Ruby Way, when it comes to .NET. If you want to write a new Dispose, def Dispose.> Finally, as you''re probably aware by now, capitalization in Ruby is not simply a matter of convention. In many cases, the parser actually treats identifiers which start with a capital letter differently than it does identifiers that start lower case. Now it turns out that method names are one of the places where Ruby doesn''t draw this distinction, but I''d guess that many Ruby programmers look at any identifier starting with a capital letter and think "that''s a constant".But given the following: def Foo "Bar" end Foo() what Ruby programmer would look at Foo and still think it is a constant? Of course, if I would have made it lowercase, the parentheses would not be necessary. My point is that the parentheses tell the reader that it is not a constant, but a method. Is there a situation where Foo could appear legally, as defined above, without parentheses and be confused for a constant? _______________________________________________ Ironruby-core mailing list Ironruby-core at rubyforge.org http://rubyforge.org/mailman/listinfo/ironruby-core
With respect to conventions the dynamic languages are the first languages that I''ve used that can actually depend on the casing (and pluralization) to work right (think active record models). Now it''s no longer part of the "readability" factor of code but it can play an important part in how a DSL works. Jay On Sat, Oct 25, 2008 at 7:59 PM, Orion Edwards <orion.edwards at open2view.com>wrote:> I used to think this kind of thing too. > > Each language (or large-subset-of-language) has it''s own conventions. > > Examples: > > gnu/posix C: lower_underscore_case > Microsoft C (eg the win32 api): UpperCamelCase > Java: lowerCamelCase > Javascript: lowerCamelCase > .NET: UpperCamelCase (except local variables which seem to be > lowerCamelCase) > ruby/python: lower_underscore_case > > While none of the languages will stop you from using any conventions you > like, it''s MUCH easier to learn to put your ego aside, and go with the > conventions. > > The simple fact is, you''re going to be reading loads of sourcecode written > by others in the form of examples and so forth, and if you get annoyed every > time you see stuff you ''hate'' - well you''re going to be having a pretty > unhappy time. > > > On 25/10/2008, at 2:11 PM, Ted Milker wrote: > > On Fri, Oct 24, 2008 at 7:54 PM, Curt Hagenlocher <curth at microsoft.com> >> wrote: >> >>> We''re thinking now that we''re going to go with the mangled version of the >>> name instead of the originally cased-version. "Dispose" just doesn''t >>> look >>> Rubyish enough. Any objections? >>> >> >> My opinion does not count for much but I love Ruby openness and hate >> the naming conventions. I much prefer camel case and .NET guidelines >> for naming than underscore and lowercase hell. I am just getting >> started with Ruby and have no intention of following the naming >> conventions if I can avoid it. IronRuby and .NET are my platform of >> choice for the future, even in its immature state. >> _______________________________________________ >> 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/20081026/d41d0b9e/attachment.html>