Brian Genisio wrote:
> It is a good idea, but I have tried this already, and it still fails.

So did I :-)

> By
> re-defining the method after attr_accessor, you blow away whatever magic
> happens that causes it to be a property at interop time.
> 
> Unless... you are suggesting that this is how it SHOULD work.

Yes, that's what I meant.

> I think either approach makes sense.  A special interop class method is nice
> because it is explicit.  Having method redefinition do the job is nice
> because it doesn't require a special class method :)
> 
> What does everyone else think?

Actually, I believe both make sense. Having method redefinition not
work simply violates at least *my* Principle of Least Astonishment, so
it needs to be fixed anyway. But it alone is not enough: sometimes you
might want to have different names for your .NET property and your
Ruby methods. A good example might be a readonly boolean property:

    prop_getter :isValid => :valid?
    def valid?
      @is_valid
    end

Actually, now that I think about it, what about just overloading
`attr_accessor` and friends? In plain Ruby, 

    attr_reader :isValid => :valid?

is illegal anyway. Together with working method redefinition, I
believe this would cover all use cases, no?

[Note: the risk is that at some time in the future, Ruby might allow
this notation to have the getter/setter names decoupled from the
instance variable names. Actually, now that I think about it, I might
suggest that right now :-) It always bugged me that you cannot simply
define boolean accessors because that would try to create a @valid?
instance variable, which is illegal.]

jwm

_______________________________________________
Ironruby-core mailing list
Ironruby-core@rubyforge.org
http://rubyforge.org/mailman/listinfo/ironruby-core

Reply via email to