Forum: IronRuby IronRuby idiom for using (IDisposable) ?

Posted by Thibaut Barrère (thbar)
on 2010-02-01 10:06
(Received via mailing list)
Hello,

Is there a built-in way to achieve what C# 'using' does, with IronRuby ?

Although it's pretty easy to roll your own (
http://myotherpants.com/2009/09/disposable-code), I'd like to use the
built-in way if there's one.

thanks!

-- Thibaut
Posted by Ivan Porto Carrero (Guest)
on 2010-02-01 10:08
(Received via mailing list)
yes

http://github.com/casualjim/ironnails/blob/master/IronNails/vendor/iron_nails/lib/core_ext/kernel.rb#L17
---
Met vriendelijke groeten - Best regards - Salutations
Ivan Porto Carrero
Blog: http://flanders.co.nz
Twitter: http://twitter.com/casualjim
Author of IronRuby in Action (http://manning.com/carrero)



On Mon, Feb 1, 2010 at 10:03 AM, Thibaut Barrère
Posted by Ivan Porto Carrero (Guest)
on 2010-02-01 10:09
(Received via mailing list)
you don't need to provide the true anymore. It was a bug a year ago and 
I
still have to update that
---
Met vriendelijke groeten - Best regards - Salutations
Ivan Porto Carrero
Blog: http://flanders.co.nz
Twitter: http://twitter.com/casualjim
Author of IronRuby in Action (http://manning.com/carrero)



On Mon, Feb 1, 2010 at 10:07 AM, Ivan Porto Carrero <
Posted by Thibaut Barrère (thbar)
on 2010-02-01 10:30
(Received via mailing list)
Thanks Ivan,

I like your version :)

Will something similar be added directly into IronRuby Kernel ?

-- Thibaut

On Mon, Feb 1, 2010 at 10:07 AM, Ivan Porto Carrero <
Posted by Ivan Porto Carrero (Guest)
on 2010-02-01 10:37
(Received via mailing list)
it's not a rubyism as such, so I don't think it actually belongs in the
core. But opinions may vary
---
Met vriendelijke groeten - Best regards - Salutations
Ivan Porto Carrero
Blog: http://flanders.co.nz
Twitter: http://twitter.com/casualjim
Author of IronRuby in Action (http://manning.com/carrero)



On Mon, Feb 1, 2010 at 10:21 AM, Thibaut Barrère
Posted by Thibaut Barrère (thbar)
on 2010-02-01 11:01
(Received via mailing list)
> it's not a rubyism as such, so I don't think it actually belongs in the
core. But opinions may vary

agreed - it's an ironrubyism :)

I think we can add it straight to the FAQ, to the very least!

-- Thibaut
Posted by Daniele Alessandri (Guest)
on 2010-02-01 11:12
(Received via mailing list)
On Mon, Feb 1, 2010 at 10:46, Thibaut Barrère 
<thibaut.barrere@gmail.com> wrote:

>> it's not a rubyism as such, so I don't think it actually belongs in the
>> core. But opinions may vary
>
> agreed - it's an ironrubyism :)

I'm definitely against adding such a feature to the core (as Ivan
said, it doesn't belong to ruby), but...

require 'ironrubysm'      # just to reuse your term, but it could be
something along these lines :-)

Maybe we can have a separate gem that groups a bunch of typical .NET
patterns in a more rubyish way. Thoughts?

--
Daniele Alessandri
http://www.clorophilla.net/
http://twitter.com/JoL1hAHN
Posted by Thibaut Barrère (thbar)
on 2010-02-01 11:19
(Received via mailing list)
> Maybe we can have a separate gem that groups a bunch of typical .NET
> patterns in a more rubyish way. Thoughts?

I think it's a nice idea; it would be a bit like Facets (
http://facets.rubyforge.org/), small bits that you can enable if you 
wish.

-- Thibaut
Posted by Orion Edwards (Guest)
on 2010-02-01 20:44
(Received via mailing list)
I also think it's a nice idea. I have a few other such methods
(Array#to_clr_a, Time#to_clr_time, and the godawful Array#to_2d_a) that 
seem
like they'd also be a good fit :-)

On Mon, Feb 1, 2010 at 11:17 PM, Thibaut Barrère
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.