Feature #6354
openRemove escape (break/return/redo/next support) from class/module scope
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.
Updated by mame (Yusuke Endoh) over 12 years ago
- 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
Updated by ko1 (Koichi Sasada) over 12 years ago
(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
Updated by ktsj (Kazuki Tsujimoto) over 12 years ago
What about yield?
I think it should also be removed if the proposal is accepted.
Updated by ko1 (Koichi Sasada) over 12 years ago
(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
Updated by ktsj (Kazuki Tsujimoto) over 12 years ago
Such as:
def f
class << self
yield
end
end
Updated by ko1 (Koichi Sasada) over 12 years ago
(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
Updated by ko1 (Koichi Sasada) about 12 years ago
- Target version set to 2.6