Empowering Symbols

Just an inane question:

The symbols as lvalues idea:

n = 1
m = 3
(n…m).each { |:n| :m = n**2 puts “#{m}” } #=> 1, 4, 9
p n #=> 1
p m #=> 3

– what are the related problems?

The way I see it, it looks pretty damn good: you get to keep the current
syntax and with a single enhancement you get both block local assignment
and variables – without breaking anything old.

Also, it sort of fits to the other idea of using foo(a: 1) as shorthand
for foo(:a => 1). Not that they are the same, but they have the same sweet
aroma about them…

I am quite willing to believe that these approaches as troublemakers, but
I’d like to understand the reasons.

On a related note, someone mentioned having gotten to the habit of using
symbols for various arcane purposes. Can you enlighten me – sounds
interesting to say the least.

– Nikodemus

Hi,

···

In message “Empowering Symbols” on 02/06/13, Nikodemus Siivola tsiivola@cc.hut.fi writes:

The symbols as lvalues idea:

n = 1
m = 3
(n…m).each { |:n| :m = n**2 puts “#{m}” } #=> 1, 4, 9
p n #=> 1
p m #=> 3

– what are the related problems?

I guess this is a different appearance of “|:a|” and “:=”
combination, i.e. “:a = n” instead of “a:=n”.

						matz.