From: "David A. Black" Date: 2008-04-24T03:31:53+09:00 Subject: Re: [RCR] Drop :: as a . synonym Hi -- On Thu, 24 Apr 2008, ara.t.howard wrote: > > On Apr 23, 2008, at 8:52 AM, Charles Oliver Nutter wrote: >> >> In JRuby we use it to allow a single delimiter for package elements when >> referring to a Java class. >> >> Given the Java class java.lang.System, you can access it as >> "java.lang.System", in which the intermediate "java" and "javalang" modules >> are accessed with dots and the "System" at the end is a method that returns >> the class, or you can access it as "java::lang::System", where the :: >> replaces the . for method calls and the "System" at the end is a direct >> constant reference. You can't do this without :: being available for method >> calls. > > bingo - i do very similar things all the time as well - thousands of lines of > code.... > > the fact that code can be refactored so > > foo::Bar > > may be module or method call is extremely useful with legacy code that need a > bit of tweaking. > > i think i've written as much, or more, that about any ruby programmer out > there and i've used this feature extensively. in fact i recently design and > api for a client which used the feature extensively and the client > specifically commented on how 'pretty' the resulting api was. > > the real question is if it causes some problem and, we know, it does not. > confusion not counting as a problem because that would lead to the removed of > *many* great ruby features. > > besides - having 'one way' to do things is the python mindset ;-) Well, between Python having "one way", and Perl having "more than one way", I prefer not to dance to either of their tunes, and just deal with Ruby as Ruby. I'm not really talking about mindsets or generalities, just one particular suggestion. One of the great things about how Ruby is designed (I mean the process, not just the results) is that it isn't based on the "Well, we've done X, and Y is kind of like X, so we'd better do Y" philosophy. Rather, if X is a bad idea, then X isn't done. If Y is a good idea, then Y is done -- even if at some level of abstract description ("confusing" being kind of an example, I guess) X and Y resemble each other. If separating the :: and the . is a good idea, then it's a good idea, and *just* doing that would be good. That's what I'm trying to explore. It would not entail removing anything else from Ruby. Anyway -- I think your technical point is interesting, though I can't help thinking that if :: had not been made a superset of ., it wouldn't stop just about any code from having been written, though perhaps in a slightly different way. David -- Rails training from David A. Black and Ruby Power and Light: INTRO TO RAILS June 9-12 Berlin ADVANCING WITH RAILS June 16-19 Berlin INTRO TO RAILS June 24-27 London (Skills Matter) See http://www.rubypal.com for details and updates!