Feature #7849
Symbol#to_str
Added by trans (SYSTEM ERROR) about 1 month ago. Updated 12 days ago.
Status: | Rejected | Start date: | 02/14/2013 | |
---|---|---|---|---|
Priority: | Normal | Due date: | ||
Assignee: | - | % Done: | 0% |
|
Category: | core | |||
Target version: | next minor |
Description
History
[ruby-core:52237]#1
Updated by Student (Nathan Zook) about 1 month ago
[ruby-core:52241]#2
Updated by trans (SYSTEM ERROR) about 1 month ago
[ruby-core:52243]#3
Updated by charliesome (Charlie Somerville) about 1 month ago
[ruby-core:52247]#4
Updated by drbrain (Eric Hodel) about 1 month ago
- Status changed from Open to Rejected
[ruby-core:52286]#5
Updated by trans (SYSTEM ERROR) about 1 month ago
[ruby-core:52287]#6
Updated by trans (SYSTEM ERROR) about 1 month ago
@charliesome Actually, that's exactly what my proposal attempts to address. You don't always have a choice in what type of object you receive, but you want it to become a string. Consider a DSL like Rake's. One could use:
task :foo do ...
Or
task 'foo' do ...
Either one is acceptable, and I think it would be overreaching to make people not be able to use a symbol here.
On the other hand do we want any object to be acceptable? B/c just about every object responds to #to_s. To avoid this, you would end up with something like: (WARNING! Fugly code ahead.)
def task(name) name = (Symbol === name ? name.to_s : name.to_str) ... end
There has to be a clearer solution than that.
P.S. Just for fun of it I tried this on rake and discovered the Jim decided not to care what get's passed to task. Try this in your Rakefile:
desc "OMG!" task Object.new do puts "OMG is right!" end
A Duck-typing true beleiver!!! Yea, looks like a bug to me. If the user really needs it they can call #to_s.
[ruby-core:52294]#7
Updated by drbrain (Eric Hodel) about 1 month ago
[ruby-core:53176]#8
Updated by trans (SYSTEM ERROR) 12 days ago
Also available in: Atom PDF