From: Thomas Hafner Date: 2009-04-25T07:10:14+09:00 Subject: Re: hygienic startup file Robert Klemme wrote/schrieb <9e3fd2c80904240015h11f3376l424a24457691b0c0@mail.gmail.com>: > The question is: why do you need constants if you want to hide them? First I defined constants rather than variables simply because each of them actually is constant rather than variable: the value never changes after assignment. In C++ I would add a const qualifier to the local variables, e.g. to prevent from unintentionally overriding it. In Haskell ther's no need for a const keyword, because all definitions are immutable per se, which is regarded a feature in this purely functional programming language. But in Ruby there are no local constants analogical to local variables, so when I simply define constants I unintentionally export them, too. (Freeze is no option, because it freezes the object hold by the variable, not the variable itself.) Every alternative has its own tradeoff: 1. If I define simple constants, I pollute the namespace of the loading code. 2. If I define constants within class << Object.new, the code is somehow ugly. 3. If I define local variables, I don't benefit from the fact that they are actually constant. So currently alternative #3 is best for me, but if somebody shows me a way to make #2 less ugly (get away from class << Object.new), that would probably my favorite. Regards Thomas