Project

General

Profile

Actions

Feature #6354

open

Remove escape (break/return/redo/next support) from class/module scope

Added by ko1 (Koichi Sasada) almost 12 years ago. Updated about 6 years ago.

Status:
Assigned
Target version:
-
[ruby-core:44612]

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) almost 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

Updated by ko1 (Koichi Sasada) almost 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) almost 12 years ago

What about yield?
I think it should also be removed if the proposal is accepted.

Updated by ko1 (Koichi Sasada) almost 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) almost 12 years ago

Such as:

def f
class << self
yield
end
end

Updated by ko1 (Koichi Sasada) almost 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) over 11 years ago

  • Target version set to 2.6
Actions #8

Updated by naruse (Yui NARUSE) about 6 years ago

  • Target version deleted (2.6)
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0Like0