From: Chris Roos Date: 2006-09-16T08:47:26+09:00 Subject: Ruby keywords vs methods Hi, I attended Jim Weirich's talk at Rails Conf on Friday. It was about thoughtful library design and contained a section on ways to mitigate risk when re-opening standard libraries. Rake uses the following pattern when adding to standard library classes... class BaseClass unless instance_methods.include? "foo" def foo # meth body here end end end It struck me that it might be quite useful to wrap this up and apply it to all methods defined for [a] given class[es]. Unfortunately, it appears not to be (completely) possible. I thought we might be able to use the method_added hook, but this gets fired after the method definition. We need something to fire right before the method definition. As def is a keyword and not a method, we can't override and add to the default behaviour. Note, that we can, however, do this with define_method. So, my actual question is, why are some things keywords and most things method calls? I think it's io (language) that doesn't have any keywords at all (so I guess it must be possible). In addition, I'm interested in whether there are there any plans to increase or decrease the number of keywords in ruby? Looking forward to some insight, Chris