From: Mathieu Bouchard Date: 2001-07-10T11:15:26+09:00 Subject: [ruby-talk:17584] Re: Constants and Variables On Tue, 10 Jul 2001, HarryO wrote: > The reason is that sometimes capital letters make sense. A contrived > example would be if I had a parameter for estimated time of arrival and > wanted to call it ETA. Rather than being forced to make it something That's a trade off. Similarly you can't call an accessor :don't_sort, although the apostrophe is part of the conventions of the english language. Also, spaces are replaced by underscores, and you can't use dashes either. > The fact that he couldn't work out what was going wrong pushed him away > from ruby for ages, [...] In his case, everyone else wrote their code in > perl, and everyone used that abbreviation, The real reason is that he had no real reason to switch in the first place. Ruby is not (just) a "cleaner Perl". On Tue, 10 Jul 2001, HarryO wrote: > > If you want objects that don't change, try Object#freeze, > > Object#frozen?. > Here's a thought ... why not just say that freeze is the only way things > are made immutable? Then, could we not have code like ... > MAX_SIZE = 100.freeze 100 is already frozen by definition because it is an unboxed object (although 100.frozen? always return false) MAX_SIZE is not an object, it's a slot in the current constants-namespace. Please distinguish objects from variables/constants. On Tue, 10 Jul 2001, HarryO wrote: > > max_size = 100.freeze > I just tried this and it doesn't work!! In fact, even if I do ... > max_size.freeze > I can still chane it. What's the story there? Obviously, I'm missing > something about how freeze works. The constness is not the point; the scope is. I think we need an alternate name for "constant" in Ruby. matju