[#79914] [Ruby trunk Bug#13282] opt_str_freeze does not always dedupe — normalperson@...
Issue #13282 has been reported by Eric Wong.
4 messages
2017/03/05
[#80140] [Ruby trunk Feature#13295] [PATCH] compile.c: apply opt_str_freeze to String#-@ (uminus) — shyouhei@...
Issue #13295 has been updated by shyouhei (Shyouhei Urabe).
5 messages
2017/03/13
[#80362] Re: [Ruby trunk Feature#13295] [PATCH] compile.c: apply opt_str_freeze to String#-@ (uminus)
— Eric Wong <normalperson@...>
2017/03/26
[email protected] wrote:
[#80368] Re: [Ruby trunk Feature#13295] [PATCH] compile.c: apply opt_str_freeze to String#-@ (uminus)
— SASADA Koichi <ko1@...>
2017/03/27
On 2017/03/26 15:16, Eric Wong wrote:
[#80205] Re: [ruby-cvs:65166] duerst:r58000 (trunk): clarifiy 'codepoint' in documentation of String#each_codepoint — Eric Wong <normalperson@...>
[email protected] wrote:
4 messages
2017/03/17
[#80213] Re: [ruby-cvs:65166] duerst:r58000 (trunk): clarifiy 'codepoint' in documentation of String#each_codepoint
— Martin J. Dürst <duerst@...>
2017/03/17
Hello Eric,
[#80290] [Ruby trunk Feature#13355] [PATCH] compile.c: optimize literal String range in case/when dispatch — normalperson@...
Issue #13355 has been reported by normalperson (Eric Wong).
4 messages
2017/03/23
[#80410] Re: [Ruby trunk Feature#13355] [PATCH] compile.c: optimize literal String range in case/when dispatch
— Eric Wong <normalperson@...>
2017/03/27
[email protected] wrote:
[#80415] [Ruby trunk Feature#12589] VM performance improvement proposal — vmakarov@...
Issue #12589 has been updated by vmakarov (Vladimir Makarov).
5 messages
2017/03/28
[#80488] [Ruby trunk Feature#12589] VM performance improvement proposal — vmakarov@...
Issue #12589 has been updated by vmakarov (Vladimir Makarov).
4 messages
2017/03/29
[ruby-core:80167] [Ruby trunk Misc#13283] Disable `&' interpreted as argument prefix warning when passing symbol to Enumerable#map
From:
dan.j.allen@...
Date:
2017-03-15 00:06:24 UTC
List:
ruby-core #80167
Issue #13283 has been updated by mojavelinux (Dan Allen).
> Just looking in stdlib, `Set#&` means set intersection, and anyone can define `#&` on any class they like to mean whatever makes sense to them - that's the joy of ruby.
Now I understand where the conflict is. Thank you for pointing that out.
However, I still say that in this case, it's actually impossible to create this situation.
Consider the following:
```
class Enumerator
def & arg
puts '& method called on Enumerator with arg ' + arg.to_s
end
end
[1, 2, 3].map &:name
```
That results in:
```
in `map': undefined method `name' for 1:Fixnum (NoMethodError)
```
Only if I remove the space (or add a ".") will it work:
```
[1, 2, 3].map&:name
```
Perhaps that is an implementation detail, but every implementation does the same thing. Visual inspection is enough to determine what will happen. And I'm pretty sure a test in ruby spec could validate this.
> it seems so much simpler to retain the warning and accept that there are some occasions when parens are either necessary or advisable to disambiguate the syntax.
All I'm pointing out is that's where Ruby becomes not my best friend.
----------------------------------------
Misc #13283: Disable `&' interpreted as argument prefix warning when passing symbol to Enumerable#map
https://bugs.ruby-lang.org/issues/13283#change-63606
* Author: mojavelinux (Dan Allen)
* Status: Open
* Priority: Normal
* Assignee:
----------------------------------------
A common idiom in Ruby is to pass a symbol reference to `Enumerable#map`, which in turn invokes the corresponding method on each entry.
Case in point:
~~~
%(a b c).map &:upcase
~~~
Yet, when warnings are enabled, this line produces the following warning:
~~~
warning: `&' interpreted as argument prefix
~~~
Perhaps we can all agree that's what this statement *should* do, and in fact Ruby does it. So there's really no reason for this warning. The alternative, a bitwise operation on a symbol, makes little sense. That's especially when the bitwise operator is directly adjacent to the symbol.
The workaround to squelch the warning is to add parentheses:
~~~
%(a b c).map(&:upcase)
~~~
However, it's one of the few cases in Ruby where parentheses are mandatory (for an isolated statement). For those of us who prefer to drop parentheses for code style, this is an irritation. It's also one of the most common warnings I've seen Ruby report when warnings are enabled, so it's also just noisy.
Can this warning be removed?
--
https://bugs.ruby-lang.org/
Unsubscribe: <mailto:[email protected]?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>