From: Trans Date: 2008-11-26T22:05:52+09:00 Subject: [ruby-core:20114] Re: [Bug #796] dynamic constant assignment On Nov 25, 1:53�pm, Yukihiro Matsumoto wrote: > Hi, > > In message "Re: [ruby-core:20096] Re: [Bug #796] dynamic constant assignment" > � � on Wed, 26 Nov 2008 03:42:29 +0900, Jim Deville writes: > > |What about a conditional dynamic assignment. It would be nice to have an idiom such as: > | > |CONST ||= "foo" > | > |I've wanted this in the initializer before, and I end up using a ternary and Module#const_set > > Please understand constants are constants. �Adding such features might > be useful for some cases, I admit, but it makes constants more and > more like mere variables. �In my opinion, making constants mere > variables do not buy you much in the long term. Indeed. And yet, I'm not sure what the current middle ground approach buys us either. You can still change them via remove_const and const_set, so what's the difference? As far as I can tell, all that accomplishes is extra hoop jumping by us programmers. It's not like Ruby's execution is optimized knowing constants won't change. trans.