At Sat, 10 Aug 2002 03:44:45 +0900,
Dave Thomas wrote:
> Could we similarly allow a '.' at the start of a statement to be
> shorthand for 'self.', so we could write
> 
>    .setter = 123
> 
> meaning
> 
>    self.setter = 123
> 
> If we had that, I might be tempted to use it for normal method calls
> too.

But what will I get from:  puts .setter = 123


Well, I know that this probrem is considered one of pit hole.  But
this syntax may lead implicitly us to a style: Use @var rather than
var() even if that is a simple attribute.  Indeed I prefer @var or
@var=val bacause the semantics of theml are simpler and clearer then
#var() or #var=(val).

In addition, @var is slightly faster than var(); Absolute differnce is
ignorable small, of course, but relative diff isn't so small.

  require "benchmark"

  class C
    attr eval(":var"), true;

    def benchmark(n)
      Benchmark::bmbm do |test|
        test.item("var()"){ n.times{ var() } }
        test.item("@var"){ n.times{ @var } }
      end
    end
  end

  C.new.benchmark(1000000)

generates:

  Rehearsal -----------------------------------------
  var()   0.960938   0.000000   0.960938 (  0.970511)
  @var    0.703125   0.000000   0.703125 (  0.729765)
  -------------------------------- total: 1.664062sec

              user     system      total        real
  var()   0.960938   0.000000   0.960938 (  1.004252)
  @var    0.695312   0.000000   0.695312 (  0.712950)

-- Gotoken