From: r2d2@... (Niklas Frykholm) Date: 2001-11-17T03:31:56+09:00 Subject: [ruby-talk:25576] Re: Constants and Variables Martin J. Laubach wrote: > The first point is the definition of constants (a symbol starting >with an upper case letter) -- WTF was it done that way, mixing >syntax and semantics, instead of having a "const" attribute. After >all, if you go down that way, ruby could define protected methods >as "starting with an underscore" or such. Let me offer a perspective that perhaps makes this seem less strange: Many languages have naming conventions for constants, functions, classes, etc to make programs easier to read. In some cases (for example Java) the conventions are so strong that violating them should be considered a programming error (for example naming a class like_this in Java). It might then be reasonable to let the compiler enforce some of the conventions (for example that constants should be upper case). But once you do that the declaration const Test = 3 will be redundant, because the naming convention is already enough to tell us and the compiler that Test is constant, so we can save some typing by removing the declaration. As you probably have noticed Ruby uses syntax instead of declarations in other cases too, e.g. $x for global variables and @x for class variables. There are advantages and drawbacks with this. The advantages are that it is easier to type (no 'public static int') and that you immediately can see what kind of variable it is without having to look for the declaration. The drawback is a slightly more complicated syntax. I think it is a price well worth paying. // Niklas