From: zdennis Date: 2006-04-08T03:29:06+09:00 Subject: Re: Simple Question About Deleting Instances -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Nathan Olberding wrote: > zdennis wrote: > >>If you want you can extend ruby to do what *you* want. Ruby gives you >>this flexibility... >> >>class Class >> def attr_class_accessor arg >> instance_eval "class << self ; attr_accessor :#{arg} ; end" >> end >>end >> >>class A >> attr_class_accessor :b >>end > > > Yes, but... that still means that someone has to think about more > implementation details than should (in my opinion) be necessary :-) You > know what I mean? > I had to think about half a second, and then type for about 8 seconds. Just copy and paste the code and put it in a file that you require on your projects, and you won't have to think. I will think for you. Matz is busy solving bigger problems and conquering better obstacles. So he doesn't have to think about this, I will put my brain to work for him. class Class def attr_class_accessor arg instance_eval "class << self ; attr_accessor :#{arg} ; end" end def attr_class_reader arg instance_eval "class << self ; attr_reader :#{arg} ; end" end def attr_class_writer arg instance_eval "class << self ; attr_writer :#{arg} ; end" end end If you feel this stronlgy about your desire to simplify this, perhaps you should submit it as an RCR, http://www.rcrchive.net. I am not saying I think your idea to simplify this into a builtin part of ruby is a bad thing, but I think that you should not abolish your ability to think. Ruby gives you power, use it. And if you think it can be made better, submit a patch or submit an RCR. Matz gives you the power to influence the langauge, I challenge you to do so. Zach -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.1 (GNU/Linux) Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org iD8DBQFENrBSMyx0fW1d8G0RAgMYAJ9vFyS/H5Jn/jYdxIZgr57y+i6N5gCfThBe zpwrWvyW5OX6BC2oJxVAo1Q= =4Jlf -----END PGP SIGNATURE-----