From: Eric Mahurin Date: 2008-04-24T07:51:47+09:00 Subject: Re: [RCR] Drop :: as a . synonym ------=_Part_10125_24539853.1208991106883 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline On Wed, Apr 23, 2008 at 3:28 PM, Eric Mahurin wrote: > On Wed, Apr 23, 2008 at 9:21 AM, David A. Black > wrote: > > > Hi -- > > > > I'd like to request the deprecation/removal of :: as a synonym for the > > method-calling dot. I think it's a good opportunity to take out > > something that Ruby doesn't need. We've already got the dot, which > > always means "send a message", and :: already means something else > > (constant resolution). > > > I'd actually prefer to go the other way and add more value to both "::" > and ".". > > a::b - gives an object named b in the scope of a > a.b - calls an object named b in the scope of a > > With this, you'd have these as equivalents: > > a::b <=> a.method(:b) > a.b <=> a::b.call > a.b(x, y) <=> a::b.call(x, y) > BTW, this does break compatibility since a::b where a is an object is an alias for a.b. But, I think the current behavior is confusing and inconsistent. I definitely agree that "::" shouldn't sometimes act as an alias for ".". Here's an example: class A class B;end def self.B;"A.B";end def self.C;"A.C";end class D;end def e;"A#e";end def F;"A#F";end end => nil irb(main):002:0> A.B => "A.B" irb(main):003:0> A::B => A::B irb(main):004:0> A.C => "A.C" irb(main):005:0> A::C NameError: uninitialized constant A::C from (irb):5 from :0 irb(main):006:0> A.D NoMethodError: undefined method `D' for A:Class from (irb):6 from :0 irb(main):007:0> A::D => A::D irb(main):008:0> a = A.new => # irb(main):009:0> a.e => "A#e" irb(main):010:0> a::e => "A#e" irb(main):011:0> a.F => "A#F" irb(main):012:0> a::F TypeError: # is not a class/module from (irb):12 from :0 From this, it is difficult to describe "::". It looks to be either: - left is a class/module: scope resolution operator - left is a non class/module and right is a uppercase name: invalid - left is a non class/module and right is a lowercase name: method call I think "::" should have one meaning: scope resolution for an object. And "." already means calling a method. Eric ------=_Part_10125_24539853.1208991106883 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline On Wed, Apr 23, 2008 at 3:28 PM, Eric Mahurin <eric.mahurin@gmail.com> wrote:
On Wed, Apr 23, 2008 at 9:21 AM, David A. Black <dblack@rubypal.com> wrote:
Hi --

I'd like to request the deprecation/removal of :: as a synonym for the
method-calling dot. I think it's a good opportunity to take out
something that Ruby doesn't need. We've already got the dot, which
always means "send a message", and :: already means something else
(constant resolution).

I'd actually prefer to go the other way and  add  more value to both "::" and ".".

a::b - gives an object named b in the scope of a
a.b - calls an object named b in the scope of a

With this, you'd have these as equivalents:

a::b <=> a.method(:b)
a.b <=> a::b.call
a.b(x, y) <=> a::b.call(x, y)

BTW, this does break compatibility since a::b where a is an object is an alias for a.b.  But, I think the current behavior is confusing and inconsistent.  I definitely agree that "::" shouldn't sometimes act as an alias for ".".

Here's an example:

class A
  class B;end
  def self.B;"A.B";end
  def self.C;"A.C";end
  class D;end
  def e;"A#e";end
  def F;"A#F";end
end
=> nil
irb(main):002:0> A.B
=> "A.B"
irb(main):003:0> A::B
=> A::B
irb(main):004:0> A.C
=> "A.C"
irb(main):005:0> A::C
NameError: uninitialized constant A::C
        from (irb):5
        from :0
irb(main):006:0> A.D
NoMethodError: undefined method `D' for A:Class
        from (irb):6
        from :0
irb(main):007:0> A::D
=> A::D
irb(main):008:0> a = A.new
=> #<A:0xb7c55a8c>
irb(main):009:0> a.e
=> "A#e"
irb(main):010:0> a::e
=> "A#e"
irb(main):011:0> a.F
=> "A#F"
irb(main):012:0> a::F
TypeError: #<A:0xb7c55a8c> is not a class/module
        from (irb):12
        from :0

From this, it is difficult to describe "::".  It looks to be either:
- left is a class/module: scope resolution operator
- left is a non class/module and right is a uppercase name: invalid
- left is a non class/module and right is a lowercase name: method call

I think "::" should have one meaning: scope resolution for an object.  And "." already means calling a method.

Eric

------=_Part_10125_24539853.1208991106883--