* [ruby-core:81559] [Ruby trunk Feature#13630] :[] method should accept block in nice syntax
[not found] <redmine.issue-13630.20170603122409@ruby-lang.org>
@ 2017-06-03 12:24 ` huukhoanguyen
2017-06-03 16:39 ` [ruby-core:81564] " shevegen
` (3 subsequent siblings)
4 siblings, 0 replies; 5+ messages in thread
From: huukhoanguyen @ 2017-06-03 12:24 UTC (permalink / raw)
To: ruby-core
Issue #13630 has been reported by khoan (khoa nguyen).
----------------------------------------
Feature #13630: :[] method should accept block in nice syntax
https://bugs.ruby-lang.org/issues/13630
* Author: khoan (khoa nguyen)
* Status: Open
* Priority: Normal
* Assignee:
* Target version:
----------------------------------------
~~~ ruby
# given
module Bam
def self.[](bam)
yield bam
end
end
# SyntaxError: unexpected keyword_do_block
Bam['bam'] do |b|
puts b
end
# SyntaxError: unexpected { arg, expecting end-of-input
Bam['bam'] { |b|
puts b
}
# Valid but more verbose
Bam.[]('bam') do |b|
puts b
end
Bam.[]('bam') { |b|
puts b
}
~~~
--
https://bugs.ruby-lang.org/
^ permalink raw reply [flat|nested] 5+ messages in thread
* [ruby-core:81564] [Ruby trunk Feature#13630] :[] method should accept block in nice syntax
[not found] <redmine.issue-13630.20170603122409@ruby-lang.org>
2017-06-03 12:24 ` [ruby-core:81559] [Ruby trunk Feature#13630] :[] method should accept block in nice syntax huukhoanguyen
@ 2017-06-03 16:39 ` shevegen
2017-08-31 5:25 ` [ruby-core:82544] " nobu
` (2 subsequent siblings)
4 siblings, 0 replies; 5+ messages in thread
From: shevegen @ 2017-06-03 16:39 UTC (permalink / raw)
To: ruby-core
Issue #13630 has been updated by shevegen (Robert A. Heiler).
I agree. I always wondered about this too.
I did not make a suggestion like this because I suspect that one reason may be a parser issue, as otherwise it would most likely have been done already.
In particular for elements without any arguments like:
Bam.[] { |b| puts b }
Or more verbose to use your example:
module Bam
def self.[](bam=42)
yield bam
end
end
Bam.[] { |b| puts b } # => 42
Bam[] { |b| puts b } # => SyntaxError: (irb):14: syntax error, unexpected { arg, expecting end-of-input
Only difference here between failure and success is one lonely '.'. I am not sure if it is technically
possible to get rid of the '.', but if it would be possible, that would be great. The '.' visually
disturbs me when I see [] ... but not at other places, it's weird. :D
----------------------------------------
Feature #13630: :[] method should accept block in nice syntax
https://bugs.ruby-lang.org/issues/13630#change-65266
* Author: khoan (khoa nguyen)
* Status: Open
* Priority: Normal
* Assignee:
* Target version:
----------------------------------------
~~~ ruby
# given
module Bam
def self.[](bam)
yield bam
end
end
# SyntaxError: unexpected keyword_do_block
Bam['bam'] do |b|
puts b
end
# SyntaxError: unexpected { arg, expecting end-of-input
Bam['bam'] { |b|
puts b
}
# Valid but more verbose
Bam.[]('bam') do |b|
puts b
end
Bam.[]('bam') { |b|
puts b
}
~~~
--
https://bugs.ruby-lang.org/
^ permalink raw reply [flat|nested] 5+ messages in thread
* [ruby-core:82544] [Ruby trunk Feature#13630] :[] method should accept block in nice syntax
[not found] <redmine.issue-13630.20170603122409@ruby-lang.org>
2017-06-03 12:24 ` [ruby-core:81559] [Ruby trunk Feature#13630] :[] method should accept block in nice syntax huukhoanguyen
2017-06-03 16:39 ` [ruby-core:81564] " shevegen
@ 2017-08-31 5:25 ` nobu
2017-09-25 12:18 ` [ruby-core:82988] [Ruby trunk Feature#13630][Closed] " shyouhei
2017-09-25 13:31 ` [ruby-core:82998] [Ruby trunk Feature#13630] " matz
4 siblings, 0 replies; 5+ messages in thread
From: nobu @ 2017-08-31 5:25 UTC (permalink / raw)
To: ruby-core
Issue #13630 has been updated by nobu (Nobuyoshi Nakada).
The trunk accepts a block after `[]` now.
----------------------------------------
Feature #13630: :[] method should accept block in nice syntax
https://bugs.ruby-lang.org/issues/13630#change-66352
* Author: khoan (khoa nguyen)
* Status: Open
* Priority: Normal
* Assignee:
* Target version:
----------------------------------------
~~~ ruby
# given
module Bam
def self.[](bam)
yield bam
end
end
# SyntaxError: unexpected keyword_do_block
Bam['bam'] do |b|
puts b
end
# SyntaxError: unexpected { arg, expecting end-of-input
Bam['bam'] { |b|
puts b
}
# Valid but more verbose
Bam.[]('bam') do |b|
puts b
end
Bam.[]('bam') { |b|
puts b
}
~~~
--
https://bugs.ruby-lang.org/
^ permalink raw reply [flat|nested] 5+ messages in thread
* [ruby-core:82988] [Ruby trunk Feature#13630][Closed] :[] method should accept block in nice syntax
[not found] <redmine.issue-13630.20170603122409@ruby-lang.org>
` (2 preceding siblings ...)
2017-08-31 5:25 ` [ruby-core:82544] " nobu
@ 2017-09-25 12:18 ` shyouhei
2017-09-25 13:31 ` [ruby-core:82998] [Ruby trunk Feature#13630] " matz
4 siblings, 0 replies; 5+ messages in thread
From: shyouhei @ 2017-09-25 12:18 UTC (permalink / raw)
To: ruby-core
Issue #13630 has been updated by shyouhei (Shyouhei Urabe).
Status changed from Open to Closed
We looked at this at a developer meeting today and confirmed that this is already done.
----------------------------------------
Feature #13630: :[] method should accept block in nice syntax
https://bugs.ruby-lang.org/issues/13630#change-66896
* Author: khoan (khoa nguyen)
* Status: Closed
* Priority: Normal
* Assignee:
* Target version:
----------------------------------------
~~~ ruby
# given
module Bam
def self.[](bam)
yield bam
end
end
# SyntaxError: unexpected keyword_do_block
Bam['bam'] do |b|
puts b
end
# SyntaxError: unexpected { arg, expecting end-of-input
Bam['bam'] { |b|
puts b
}
# Valid but more verbose
Bam.[]('bam') do |b|
puts b
end
Bam.[]('bam') { |b|
puts b
}
~~~
--
https://bugs.ruby-lang.org/
^ permalink raw reply [flat|nested] 5+ messages in thread
* [ruby-core:82998] [Ruby trunk Feature#13630] :[] method should accept block in nice syntax
[not found] <redmine.issue-13630.20170603122409@ruby-lang.org>
` (3 preceding siblings ...)
2017-09-25 12:18 ` [ruby-core:82988] [Ruby trunk Feature#13630][Closed] " shyouhei
@ 2017-09-25 13:31 ` matz
4 siblings, 0 replies; 5+ messages in thread
From: matz @ 2017-09-25 13:31 UTC (permalink / raw)
To: ruby-core
Issue #13630 has been updated by matz (Yukihiro Matsumoto).
And now mruby does too.
Matz.
----------------------------------------
Feature #13630: :[] method should accept block in nice syntax
https://bugs.ruby-lang.org/issues/13630#change-66907
* Author: khoan (khoa nguyen)
* Status: Closed
* Priority: Normal
* Assignee:
* Target version:
----------------------------------------
~~~ ruby
# given
module Bam
def self.[](bam)
yield bam
end
end
# SyntaxError: unexpected keyword_do_block
Bam['bam'] do |b|
puts b
end
# SyntaxError: unexpected { arg, expecting end-of-input
Bam['bam'] { |b|
puts b
}
# Valid but more verbose
Bam.[]('bam') do |b|
puts b
end
Bam.[]('bam') { |b|
puts b
}
~~~
--
https://bugs.ruby-lang.org/
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2017-09-25 13:32 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <redmine.issue-13630.20170603122409@ruby-lang.org>
2017-06-03 12:24 ` [ruby-core:81559] [Ruby trunk Feature#13630] :[] method should accept block in nice syntax huukhoanguyen
2017-06-03 16:39 ` [ruby-core:81564] " shevegen
2017-08-31 5:25 ` [ruby-core:82544] " nobu
2017-09-25 12:18 ` [ruby-core:82988] [Ruby trunk Feature#13630][Closed] " shyouhei
2017-09-25 13:31 ` [ruby-core:82998] [Ruby trunk Feature#13630] " matz
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).