[Ironruby-core] Lowercase classname
blowmage at gmail.com
Fri Nov 19 12:39:49 EST 2010
I disagree. You don't need to be able to modify the .NET source code to get
this to work. You can use Ruby to make Ruby happy. The reason for the
friction is because .NET != Ruby. When you create a class in Ruby, you are
actually creating an object that inherits from Class, and then you are
creating a constant that points to that object. In Ruby all constants start
with an upper case character. Ruby doesn't allow you to create a class that
starts with a lower case letter.
> class foo; def to_s; puts 'wha?!'; end; end
SyntaxError: (irb):1: class/module name must be CONSTANT
class foo; def to_s; puts 'wha?!'; end; end
IronRuby does a lot of work to match Ruby's conventions of snake_case
methods, but it cannot resolve a lower case namespace or class from .NET. I
think IronRuby is doing the right thing here. Its very simple to setup your
Ruby constants that point to your .NET namespaces and classes using the
method shown in the URL provided.
Foo = Object.const_get("foo")
Foo::Bar = Foo.const_get("bar")
bar = Foo::Bar.new
Ruby is awesome but it is not infinitely flexible. You gotta jump to Lisp
for that. :)
On Fri, Nov 19, 2010 at 8:48 AM, andrew Wilson <a.wilson82 at gmail.com> wrote:
> This is only an acceptable solution if the user has the source code and is
> capable of modifying it. For how I test things with IronRuby, this isn't
> always possible. Seems odd to me that one of the most flexible language I
> know of can't read/integrate with another language due to code not following
> a rigid structure.
> Doesn't IronPython allow for this? I was fairly sure I could import
> non-standard .Net convention based code into it.
> On Fri, Nov 19, 2010 at 2:41 PM, Shay Friedman <shay.friedman at gmail.com
> > Look here:
> > <
> > Shay.
> Excellent solution. I mean, really, all the C# classes should start with an
> uppercase letter, thats basically a standard, therefore this should be the
> only solution and I don't see no need to actually hack this otherwise into
> “If I had six hours to chop down a tree, I’d spend the first four of them
> sharpening my axe”.
> -Abraham Lincoln
> Ironruby-core mailing list
> Ironruby-core at rubyforge.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Ironruby-core