From: Florian Gross Date: 2005-01-25T05:40:51+09:00 Subject: Re: attr Trans wrote: > In the upcoming release of Ruby Carats I have a little lib called > attr.rb. > > . attr :a, :a= > . attr :a?, :b! Quite nifty, all that. I don't quite understand the people who think it is obscure or who think it clutters the built-in methods. This is a nice extension. While I would not use attr :a, :a= over attr_accessor :a (the latter has already become a convention) I could see myself using this because of the attr :a?, :a= and attr :x => :to_s functionality. What I don't quite understand is why you're not remaining compatible with the original attr(). After all you would just have to check if you have two arguments of which the second is either false or true. (While this would still be slightly incompatible in the attr :foo, "I like to use Strings for true" case I'm pretty sure you can safely ignore it. Maybe a note ought to go into the documentation, but I can't see this causing trouble.) 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? Perhaps you could also allow it to take a block that would be instance_eval()uated in the method at the beginning. That could be used for introducing checks, converting values and so on. It would not provide much above writing the method out, but it could still make sense.