Issue #4877 has been updated by Lazaridis Ilias.


Yukihiro Matsumoto wrote:
> Expanding non-prefixed variables/expressions are too easy to conflict.  For example, you will have problem to print a string like "Foo#bar".  It would print "Foonil" or whatever depends on the value of the local variable bar.  For me, that is annoying too much.

I understand this, but:
 * a typical user does not use "Class#method" often. 
 * Even if, he could simply uses "Class\#method".

Subjecting the issue-processing:

why are you so eager to "reject" immediately? I understand that "Rejected" means that the issue topic is closed, and it will not dealt with. 

But the issue topic is "Unify Variable Expansion within Strings", is a good goal, for the users benefit. And it can happen in other ways, too.

Examples are:

 * puts "#$g #@@c #@i ##l ##f" (typing "#" twice is still very fast)
 * puts "~$g ~@@c ~@i ~l ~f"   (unify variable expansion based on another char, usual way via # and #{} remains)

There are other possible ways, but with a "rejected" you discourage any discussion.



----------------------------------------
Feature #4877: Unify Variable Expansion within Strings
http://redmine.ruby-lang.org/issues/4877

Author: Lazaridis Ilias
Status: Rejected
Priority: Normal
Assignee: Yukihiro Matsumoto
Category: core
Target version: 


class VarTester
  $g = "global" 
  @@c = "class"
  
  def f
    "function"
  end

  def initialize
    @i = "instance"
    l = "local"
    puts "#$g #@@c #@i #l #f #{l} #{f}"
  end
end

VarTester.new 

#=> global class instance #l #f local function

=== User Context ===

3 variable types (Class- instance- and global) can be expanded by prefixing a single char ("#") (without the need to add "{}").

This should be enabled for local vars and ideally for functions, too (at least the attr accessors).

=== Pro ===

* consistent expansion of all variable types via "#"
* reduced typing (use of {} is optional)
* increased readability of strings which contain many variables.

=== Contra ===

?

=== Compatibility ===

This would break slightly existent behaviour:

 existent '#text' within strings would be expanded (should be a rare case)






-- 
http://redmine.ruby-lang.org