[Ironruby-core] Linq etc.

Mike Moore blowmage at gmail.com
Mon Jan 21 18:57:33 EST 2008

On Jan 21, 2008 4:45 PM, John Messerly <jomes at microsoft.com> wrote:

> Yup, you need to require the assembly. If you were writing Linq in Ruby,
> you'd have something like System.Core.rb:
> module Enumerable
>  def order_by
>    ...
>  end
>  def where
>    ...
>  end
> end
> ... so requiring System.Core just opens up Enumerable and sticks some
> methods on it.
> At least, that's been my thinking on it.

I gotcha.  So in your example System.Core.rb was monkey-patching
Enumerable.  You weren't actually resolving those method calls to the
extension methods in the System.Linq.Enumerable class.

> Maybe we add an extra step like:
> require 'System.Core'
> include System::Linq
> I'm not sure how Ruby-ish that is, though.

I agree.  In C# you add the namespace and those extension methods are only
available in that source file.  So you have to add the namespace to each
file you want to use the extension methods.  But in Ruby once they are added
to the object they are available everywhere.  So I wonder what a Ruby-ish
solution would be.  Does anyone on the list have any suggestions how
enabling extension methods could/should look?

> - John
> _______________________________________________
> 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/20080121/4e5c0de3/attachment.html 

More information about the Ironruby-core mailing list