----- Original Message ----- From: "Tobias Reif" <tobiasreif / pinkjuice.com> To: "ruby-talk ML" <ruby-talk / ruby-lang.org> Sent: Tuesday, January 15, 2002 2:02 PM Subject: Re: how to get all the reserved words? > > Here is my list. (I think yours has some that are not > > really reserved, such as __FILE__.) > > Hmm; they are included in the list in RiaN, p9. OK, I was working from an older doc... obviously Matz's book supersedes anything I have to say. > > break case class def defined > > should that be "defined?" ? Yes... I guess so. I'm always confused as to whether the ? is a real part of a word or just a suffix. > > Actually, I'm questioning nil, true, and false also; > Why? (I think they are reserved words, and RiaN includes them in the list.) I read something that classified these as pseudo- variables... we usually don't think of variables as reserved words, do we? (My old Pascal background is showing, perhaps -- I always distinguished sharply between reserved words and predefined identifiers.) But again, I don't have _RiaN_ yet... I am sure that (barring possible minor errors) it is authoritative. > > Of course, even a reserved word isn't really reserved. > > For example, you can define a method called "in" > > if you wish. It's a matter of context. > > In a generated set of classes with sets of methods, Ruby choked on > method names "in", "begin", and "end" (could also have been "in=" etc.), > so I simply avoid anything that could cause trouble, and use different > names where collisions could occur. > > RiaN says: "These reserved word may not be used as constant or local > variable names. They can, however, be used as method names if a receiver > is specified." > Can anyone provide examples for this? Here's one little example. Works for me on 1.6.1 -- doesn't it work for you? class MyClass def begin puts "Hello" end end obj = MyClass.new obj.begin Hal Fulton