From: Julian Snitow Date: 2003-05-28T06:42:14+09:00 Subject: Re: Constant Definitions and Hiding On Tue, 27 May 2003 13:32:13 +0200, Robert Klemme wrote: > > "Julian Snitow" schrieb im Newsbeitrag > news:pan.2003.05.27.10.23.28.960550@yahoo.com... >> On Tue, 27 May 2003 09:55:03 +0200, Robert Klemme wrote: >> [snipsnip] >> > Hm, maybe it's a question of expectations. OTOH I found it surprising >> > that defining a singleton method that had been defined as a singleton >> > method issues a warning, too. But I can see, that it's reasonable to > warn >> > about this. >> >> I submit that referring to an unqualified BAR usually indicates that the >> programmer probably intended for the local BAR to be used, as opposed to >> specifying Foo::BAR. I can think of several examples in which I might >> legitimately want to extend a subclass's behavior by setting a new BAR, >> and since Ruby already offers a clear, concise way to specify which of > the >> two cases you want, I think it's better to err on the side of >> extensibility. > > ... leading you to which conclusion? Sorry, I don't get what you indend > to say be "it's better to err on the side of extensibility". By "extensibility" I mean the ability to change as much of a (sub)class's behavior at runtime without being warned; I favor the "trust the programmer" approach of permitting the definition of FooSubClass::BAR, on the theory that the implicit/explicit scoping rules are there for a reason, and that defining class Bar < Foo; BAR = "something else"; end, doesn't wipe out the definition of Foo::BAR. Any unintended side-effects, then, are localized, and will be caught during the debugging of class Bar. You'll note that if you redefine Foo::BAR in two different places, you're already warned, so your proposed warning can't be justified on the grounds that Bar::BAR would interfere with the operation of class Foo. (*whew!* ;-) > >> (Of course, since I'm aesthetically biased against the use of CONSTANTS > inside a >> class definition anyway, my opinion in this matter is "for entertainment >> purposes only"! ;-) > > You might be pleased to hear that I found your comments entertaining and > interesting. :-) > Thanks! :) Cheers, Julian