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: [EMAIL PROTECTED] [EMAIL PROTECTED] On Behalf Of Ted Milker [EMAIL 
PROTECTED]
Sent: Saturday, October 25, 2008 11:12 PM
To: ironruby-core@rubyforge.org
Subject: Re: [Ironruby-core] Overriding CLS Virtuals

On Sun, Oct 26, 2008 at 12:20 AM, Curt Hagenlocher <[EMAIL PROTECTED]> 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@rubyforge.org
http://rubyforge.org/mailman/listinfo/ironruby-core

_______________________________________________
Ironruby-core mailing list
Ironruby-core@rubyforge.org
http://rubyforge.org/mailman/listinfo/ironruby-core

Reply via email to