From: dblack@... Date: 2007-03-01T11:50:46+09:00 Subject: Re: object_* and instance_* methods Hi -- On Thu, 1 Mar 2007, Daniel DeLorme wrote: > A while back there was a proposal to use a standard naming scheme for > meta-programming methods. It went like this: > > object_id > object_class (instead of class) > object_send (instead of send) > object_method (instead of method) Why object_method? > Then for all the methods that bypass access restrictions: > > instance_send (instead of funcall) > instance_eval > instance_exec I wish there were a way to name these without components to the name that you have to "just know". I actually don't know the difference between instance_eval and instance_exec, and I suspect I will be looking it up frequently in the future :-) I'm certainly in favor of not having funcall, for reasons enumerated at length in earlier threads (q.v. if you have some spare time...). I've lost track a bit of where that stands. > instance_variable_get > instance_variable_set > instance_variables > > The discussion didn't go much farther then but I'd like to reignite the > bikeshed. Personally I think it's a brilliant idea; sure the method names are > longer but that seems perfectly acceptable to me since meta-programming > should not be used that often. I'd say it's more that they should be reasonably conspicuous. > The naming is consistent and obvious, it > avoids ugliness like __send__, it reduces chances of naming conflict > (CgiRequest#method, Email#send), it allows a simple pattern match to > recognize any meta-programming methods, and it's already half implemented. > Are there any other people who support this idea? I'm more interested in the individual decisions -- like avoiding __send__ by having some relatively non-vulnerable alternative. I'm not big on grouping "metaprogramming" methods together, and I wouldn't want to see decisions made collectively for them. I think a lot of what's great about Ruby is how hand-crafted it is, so to speak. But I think most of the names you've suggested sound good. I'm not sure about object_method, though. David -- Q. What is THE Ruby book for Rails developers? A. RUBY FOR RAILS by David A. Black (http://www.manning.com/black) (See what readers are saying! http://www.rubypal.com/r4rrevs.pdf) Q. Where can I get Ruby/Rails on-site training, consulting, coaching? A. Ruby Power and Light, LLC (http://www.rubypal.com)