[Ironruby-core] Generic method synxtax
Jimmy.Schementi at microsoft.com
Fri Jan 9 17:49:48 EST 2009
Let's let Tomas implement content.method(:load).of(Texture2D).call(“mytexture”) ... and then we can play around with the different syntax in context. Then it's pick-the-syntax-you-want =)
From: ironruby-core-bounces at rubyforge.org [mailto:ironruby-core-bounces at rubyforge.org] On Behalf Of Ryan Riley
Sent: Friday, January 09, 2009 1:51 PM
To: ironruby-core at rubyforge.org
Subject: Re: [Ironruby-core] Generic method synxtax
I like Tomas's idea the best. Generics are not native to Ruby, so most people using them will likely have a C#/VB background, which means Tomas's syntax would be more familiar.
The "_of" syntax isn't bad, but forcing a ".do" or ".call" at the end isn't ideal, even if it does have a bit of a Ruby flavor.
Adding a ".of()" to the class is okay, but many classes may have generic methods even when the class itself is not a generic. (I'm thinking primarily of static and extension method classes here.)
Passing the generic types as the first parameters seems the most explicit and understandable translation to me.
On Fri, Jan 9, 2009 at 3:12 PM, Jimmy Schementi <Jimmy.Schementi at microsoft.com<mailto:Jimmy.Schementi at microsoft.com>> wrote:
Here are the ideas that stand out to me:
I like Tomas's idea, since it reads like C#/VB, but adding an argument to the front urks me:
content.load of(Texture2D), "mytexture"
Shri, having the "_of" appended to a generic method name and requiring a ".do" after it is how you would work with lambdas (except you do ".call"), but since we're talking about .NET methods, not .NET delegates. So, I'd like the syntax to look more like a method call. Also, as Tomas says, mangling gets more complicated ...
How about adding an "of" method to the class/object, to put the class in a generic "mode"? The method probably shouldn't be called "of", but you get the idea. It reads different than C#, but seems the most Rubyesk without changing the arguments.
Thoughts? If no one likes my idea, I think Tomas's is a fine compromise.
ryan.riley at panesofglass.org<mailto:ryan.riley at panesofglass.org>
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Ironruby-core