From: Kornelius Kalnbach Date: 2010-02-13T02:29:12+09:00 Subject: [ruby-core:28158] Documentation for const_missing This is a multi-part message in MIME format. --------------040606020609090902000600 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Hello! I came upon this while answering Yehuda's const_missing proposal. The current documentation for the method seems odd. Can we rewrite the following rant in the documentation of const_missing? [...] The following code is a (very bad) example: if reference is made to an undefined constant, it attempts to load a file whose name is the lowercase version of the constant (thus class +Fred+ is assumed to be in file +fred.rb+). If found, it returns the value of the loaded class. It therefore implements a perverse kind of autoload facility. It's not perverse, it's useful. If it really was a bad code example, it should not be in the documentation at all (unless we want to say that using const_missing is generally discouraged?). So, here's a more neutral version, removing "(very bad)" and "perverse". Patch attached (for trunk); earlier Ruby versions are affected as well. [murphy] --------------040606020609090902000600 Content-Type: text/plain; x-mac-type="0"; x-mac-creator="0"; name="const_missing_doc.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="const_missing_doc.diff" Index: variable.c =================================================================== --- variable.c (revision 26631) +++ variable.c (working copy) @@ -1368,12 +1368,12 @@ * Invoked when a reference is made to an undefined constant in * mod. It is passed a symbol for the undefined constant, and * returns a value to be used for that constant. The - * following code is a (very bad) example: if reference is made to + * following code is an example: if reference is made to * an undefined constant, it attempts to load a file whose name is * the lowercase version of the constant (thus class Fred is * assumed to be in file fred.rb). If found, it returns the - * value of the loaded class. It therefore implements a perverse - * kind of autoload facility. + * value of the loaded class. It therefore implements a kind of autoload + * facility. * * def Object.const_missing(name) * @looked_for ||= {} --------------040606020609090902000600--