From: Trans Date: 2005-01-26T10:25:50+09:00 Subject: Re: attr Thanks for the support Florian. > What I don't quite understand is why you're not > remaining compatible with the original attr(). An excellent point! All things being equal, I will do exactly that. Thanks! > Oh, and I think that the :x! feature is quite useless. This is > an extremely rare special case and I think it's more obvious > if written out. Or did you find lots of use cases for it? No. The only thing that comes to mind is in combination with a casting. Somthing like: | attr :a! => :upcase which creates | def a!(x) | @a.replace(x.upcase) | end Better, but still doesn't seem all that useful really --as has been pointed out. I've though about using the ! to build a reader and writer, but that doesn't fit the profile. ! has a general meaning of effecting the object in a special internal way. There is also another form which I thought might be nice to have, a getter/setter: If an argument is given it acts as a setter, if not it acts as a getter. But I have no simple notion to use for it. At the moment it can be done like this: | attr :"a()" But I'm not too sure about it. > Perhaps you could also allow it to take a block that would > be instance_eval()uated in the method at the beginning. I've thought about that. In fact I think I had that in there at one point. But like you say it seemed like you'd might as well be writting the method out at that point. But maybe there's merit to it for other reasons --sometimes I wish def itself took a block form, eg. | def a { #... } T.