Feature #6354
open
Remove escape (break/return/redo/next support) from class/module scope
Added by ko1 (Koichi Sasada) over 12 years ago.
Updated almost 7 years ago.
Description
Let's remove global escape (break/return/redo/next support) from class/module scope.
Yes, it introduces incompatibility. However, anyone use it?
I think the following examples are evil (difficult to understand).
examples:¶
1.times{
class C
break # break from 1.times
end
}
1.times{
class C
module M
break # break from 1.times
end
end
}
3.times{|n|
p n # repeat print 0
class C
redo
end
}
->{
class C
return return from outer lambda block
end
}.call
->{
proc{
class C
return # return from outer lambda (not proc) block
end
}.call
}.call
etc, etc.
- Status changed from Open to Assigned
I don't object, but just curious.
By removing it, what advantage will we get?
--
Yusuke Endoh mame@tsg.ne.jp
(2012/04/25 12:37), mame (Yusuke Endoh) wrote:
By removing it, what advantage will we get?
It simplifies VM implementation.
--
// SASADA Koichi at atdot dot net
What about yield?
I think it should also be removed if the proposal is accepted.
(2012/04/28 0:37), ktsj (Kazuki Tsujimoto) wrote:
What about yield?
I think it should also be removed if the proposal is accepted.
Example?
--
// SASADA Koichi at atdot dot net
Such as:
def f
class << self
yield
end
end
(2012/04/30 10:16), ktsj (Kazuki Tsujimoto) wrote:
Issue #6354 has been updated by ktsj (Kazuki Tsujimoto).
Such as:
def f
class << self
yield
end
end
Ah, singleton class... I agree with you.
BTW, the following code causes syntax error. It is inconsistency.
def m
1.times{
class << ''
break
end
}
end
--
// SASADA Koichi at atdot dot net
- Target version set to 2.6
- Target version deleted (
2.6)
Also available in: Atom
PDF
Like0
Like0Like0Like0Like0Like0Like0Like0Like0