[Ironruby-core] Generic method synxtax

Ryan Riley ryan.riley at panesofglass.org
Fri Jan 9 17:32:57 EST 2009


How would this look for instantiating a generic object?

my_object = Foo.method(:new).of(Bar).call

That seems strange. Perhaps we need to possibilities: the above for generic
methods and the following for generic classes:

my_object = Foo.of(Bar).new
# where Foo would be defined as Foo<T> in C#

my_clone = my_object.clone
# where clone would have a C# signature of T Clone<T>()

or should that be:

my_clone = my_object.method(:clone).of(Bar).call?
# and allow my_object.clone to have an overloaded
# C# signature of object Clone()?

~Ryan

On Fri, Jan 9, 2009 at 3:45 PM, Tomas Matousek <Tomas.Matousek at microsoft.com
> wrote:

>  Mine has also an issue that just occurred to me. If you do:
>
>
>
> class C
>
>   content.load of(Texture2D), "foo"
>
> end
>
>
>
> "of" resolves to Module#of which would return a C<Texture2D> if C was a
> generic type or throws an exception.
>
> So that's not good either. We would need a different method name for
> generic method constructor than for generic type. Maybe "method_of"?
>
>
>
> As for your idea:
>
> content.of(T).load
>
>
>
> is looks backwards. The content is not of T… the load is. I think this
> would be confusing.
>
>
>
> Until we figure out some nice clean solution that works in 100% cases, I
> would implement the following as the first step for generic method support:
>
>
>
> content.method(:load).of(Texture2D).call("mytexture")
>
>
>
> (Note, you can do the same in Ruby for regular methods:
> "foo".method(:center).call(100))
>
>
>
> anything else is just a convenience and anyone could define it via standard
> Ruby means.
>
>
>
> Tomas
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://rubyforge.org/pipermail/ironruby-core/attachments/20090109/b11e7cdf/attachment.html>


More information about the Ironruby-core mailing list