Rick DeNatale wrote:
> Personally, I don't see making code golfers happy as a priority over clarity.
David A. Black wrote:
> Line noise fans, likewise :-)  Sorry, but that really is the first
> thing that springs to mind. (): (()) for nil => nil is not my cup of
> tea.
please don't take this serious. I was only pointing out the worst-case
ends of this; and the () thing wasn't my idea ;)

the real target of my proposal is not code golfing, but less surprise
and improved readability: I'd expect { 'foo': 'bar' } to work, and I
think { 1:2, 3:4 } is a very nice way to write numeric hashes.

Nobu wrote:
> You can't write ([1,2,3])::a, since :: is a class path
> separator.
oh yes, my bad. I don't want to write this.

> In Ruby, it is impossible to tell if a method is defined until
> the execution reached.
I meant everything that is accepted by the current colon notation as a
key. this includes everything that looks like a method (excluding
setters), local variable, or constant identifier: [A-Za-z_][A-Za-z_0-9]*[!?]

by the way, I applied your patch (thanks!) - tests run, but the ripper
fails:
> compiling ripper
> bison -t -v -oripper.c ripper.y
> ripper.y:4420: type clash (`val' `') on default action
> ripper.y:4421: type clash (`val' `') on default action
(i686-darwin8.10.1)

even the most weird examples I could imagine run as I expect :D

  irb(main):001:0> { a: 4 }
  => {:a=>4}
  irb(main):002:0> a = 4; { a: 4 }
  => {:a=>4}
  irb(main):003:0> a = 4; { (a): 4 }
  => {4=>4}
  irb(main):004:0> a = 4; { A: 4 }
  => {:A=>4}
  irb(main):005:0> a = 4; { (A): 4 }
  NameError: uninitialized constant A
  irb(main):009:0> { (foo = Foo = 5): 5, (/default/): 0, (()): (()),
   ({a:0}):0, ([1,2,3]): :a, (ENV.keys.map(&:upcase)): :":", (foo): 7,
   (Foo): 7, foo: 7 }
  => {5=>7, /default/=>0, nil=>nil, {:a=>0}=>0, [1, 2, 3]=>:a,
  ["TERM_PROGRAM", "TERM", ...]=>:":", :foo=>7}

...along with all of my examples in the first post of this thread (apart
from the :: error you pointed out.)

that was the wizardry I was hoping for. so it comes down to a design
decision. thank you, Nobu!
[murphy]