I’ve noticed calling .freeze on a native .NET class does not have any
effect (other than making #frozen? Return true)
Is this by design?
Thanks,
Nathan
I’ve noticed calling .freeze on a native .NET class does not have any
effect (other than making #frozen? Return true)
Is this by design?
Thanks,
Nathan
It has an effect:
System::Collections::ArrayList.freeze
=> System::Collections::ArrayList
class System::Collections::ArrayList
… def foo
… end
… end
:0: can’t modify frozen class (TypeError)
Is there another effect you expect?
Tomas
From: [email protected]
[mailto:[email protected]] On Behalf Of Nathan Stults
Sent: Wednesday, December 09, 2009 12:47 PM
To: [email protected]
Subject: [Ironruby-core] Frozen .NET objects
I’ve noticed calling .freeze on a native .NET class does not have any
effect (other than making #frozen? Return true)
Is this by design?
Thanks,
Nathan
I was freezing a live instance of a custom .NET class and half expecting
property setters to become immutable, but I can imagine that would be
pretty hard to implement. I do have a related question though - I would
like to provide a read-only copy of some custom .NET DTO’s to a ruby
script - my thinking was to inherit an adapter from DynamicObject and
provide no-op implementation for all by TryGetMember - which is easy
enough to do via reflection, but is there an easy way to tap into the
DLR’s capability of doing this in a name-mangling way - i.e. a way to
implement TryGetMember that somehow re-uses what the DLR is doing behind
the scenes when integrating with a native .NET object?
From: [email protected]
[mailto:[email protected]] On Behalf Of Tomas M.
Sent: Wednesday, December 09, 2009 2:06 PM
To: [email protected]
Subject: Re: [Ironruby-core] Frozen .NET objects
It has an effect:
System::Collections::ArrayList.freeze
=> System::Collections::ArrayList
class System::Collections::ArrayList
… def foo
… end
… end
:0: can’t modify frozen class (TypeError)
Is there another effect you expect?
Tomas
From: [email protected]
[mailto:[email protected]] On Behalf Of Nathan Stults
Sent: Wednesday, December 09, 2009 12:47 PM
To: [email protected]
Subject: [Ironruby-core] Frozen .NET objects
I’ve noticed calling .freeze on a native .NET class does not have any
effect (other than making #frozen? Return true)
Is this by design?
Thanks,
Nathan
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs