summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--class.c2
-rw-r--r--eval.c200
-rw-r--r--ext/tk/lib/tk.rb28
-rw-r--r--ext/tk/lib/tkcanvas.rb6
-rw-r--r--ext/tk/lib/tkentry.rb2
-rw-r--r--ext/tk/lib/tktext.rb8
-rw-r--r--gc.c2
-rw-r--r--hash.c2
-rw-r--r--intern.h2
-rw-r--r--lib/irb/ruby-lex.rb4
-rw-r--r--lib/mkmf.rb2
-rw-r--r--lib/net/imap.rb4
-rw-r--r--lib/optparse.rb30
-rw-r--r--lib/rexml/parsers/sax2parser.rb2
-rw-r--r--lib/tracer.rb2
-rw-r--r--sample/test.rb34
-rw-r--r--signal.c2
-rw-r--r--variable.c2
19 files changed, 162 insertions, 177 deletions
diff --git a/ChangeLog b/ChangeLog
index 0e5dd5d6c7..72309c6509 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Mon Jun 16 16:06:47 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (proc_alloc): re-unification of Block and Proc. Block
+ class is no longer available.
+
Mon Jun 16 14:43:14 2003 WATANABE Hirofumi <eban@ruby-lang.org>
* bcc32/Makefile.sub: undefine HAVE_GETGROUPS.
diff --git a/class.c b/class.c
index 2c802f819c..68d908665e 100644
--- a/class.c
+++ b/class.c
@@ -879,7 +879,7 @@ rb_scan_args(argc, argv, fmt, va_alist)
if (*p == '&') {
var = va_arg(vargs, VALUE*);
if (rb_block_given_p()) {
- *var = rb_block_new();
+ *var = rb_block_proc();
}
else {
*var = Qnil;
diff --git a/eval.c b/eval.c
index 04697f48a5..0d25a620ea 100644
--- a/eval.c
+++ b/eval.c
@@ -95,7 +95,7 @@ char *strrchr _((const char*,const char));
VALUE rb_cBlock, rb_cProc;
static VALUE rb_cBinding;
-static VALUE block_invoke _((VALUE,VALUE,VALUE,VALUE));
+static VALUE proc_invoke _((VALUE,VALUE,VALUE,VALUE));
static VALUE rb_f_binding _((VALUE));
static void rb_f_END _((void));
static VALUE rb_f_block_given_p _((void));
@@ -635,7 +635,7 @@ struct BLOCK {
#define BLOCK_D_SCOPE 1
#define BLOCK_DYNAMIC 2
#define BLOCK_ORPHAN 4
-#define BLOCK_PROC 8
+#define BLOCK_LAMBDA 8
static struct BLOCK *ruby_block;
@@ -2258,12 +2258,12 @@ call_trace_func(event, node, self, id, klass)
PUSH_TAG(PROT_NONE);
if ((state = EXEC_TAG()) == 0) {
srcfile = rb_str_new2(ruby_sourcefile?ruby_sourcefile:"(ruby)");
- block_invoke(trace_func, rb_ary_new3(6, rb_str_new2(event),
- srcfile,
- INT2FIX(ruby_sourceline),
- id?ID2SYM(id):Qnil,
- self?rb_f_binding(self):Qnil,
- klass),
+ proc_invoke(trace_func, rb_ary_new3(6, rb_str_new2(event),
+ srcfile,
+ INT2FIX(ruby_sourceline),
+ id?ID2SYM(id):Qnil,
+ self?rb_f_binding(self):Qnil,
+ klass),
Qundef, 0);
}
POP_TMPTAG(); /* do not propagate retval */
@@ -3232,7 +3232,7 @@ rb_eval(self, n)
if (ruby_scope->local_vars == 0)
rb_bug("unexpected block argument");
if (rb_block_given_p()) {
- result = rb_block_new();
+ result = rb_block_proc();
ruby_scope->local_vars[node->nd_cnt] = result;
}
else {
@@ -4895,7 +4895,7 @@ rb_call0(klass, recv, id, oid, argc, argv, body, nosuper)
break;
case NODE_BMETHOD:
- result = block_invoke(body->nd_cval, rb_ary_new4(argc, argv), recv, klass);
+ result = proc_invoke(body->nd_cval, rb_ary_new4(argc, argv), recv, klass);
break;
case NODE_SCOPE:
@@ -6379,7 +6379,7 @@ call_end_proc(data)
ruby_frame->self = ruby_frame->prev->self;
ruby_frame->last_func = 0;
ruby_frame->last_class = 0;
- block_invoke(data, rb_ary_new2(0), Qundef, 0);
+ proc_invoke(data, rb_ary_new2(0), Qundef, 0);
POP_FRAME();
POP_ITER();
}
@@ -6389,7 +6389,7 @@ rb_f_END()
{
PUSH_FRAME();
ruby_frame->argc = 0;
- rb_set_end_proc(call_end_proc, rb_block_new());
+ rb_set_end_proc(call_end_proc, rb_block_proc());
POP_FRAME();
}
@@ -6398,8 +6398,7 @@ rb_f_at_exit()
{
VALUE proc;
- proc = rb_f_lambda();
-
+ proc = rb_block_proc();
rb_set_end_proc(call_end_proc, proc);
return proc;
}
@@ -6711,7 +6710,7 @@ frame_dup(frame)
}
static VALUE
-block_clone(self)
+proc_clone(self)
VALUE self;
{
struct BLOCK *orig, *data;
@@ -6775,26 +6774,26 @@ rb_f_binding(self)
return bind;
}
-#define BLOCK_T3 FL_USER1
-#define BLOCK_T4 FL_USER2
-#define BLOCK_TMAX (FL_USER1|FL_USER2)
-#define BLOCK_TMASK (FL_USER1|FL_USER2)
+#define PROC_T3 FL_USER1
+#define PROC_T4 FL_USER2
+#define PROC_TMAX (FL_USER1|FL_USER2)
+#define PROC_TMASK (FL_USER1|FL_USER2)
static void
-block_save_safe_level(data)
+proc_save_safe_level(data)
VALUE data;
{
if (OBJ_TAINTED(data)) {
switch (ruby_safe_level) {
case 3:
- FL_SET(data, BLOCK_T3);
+ FL_SET(data, PROC_T3);
break;
case 4:
- FL_SET(data, BLOCK_T4);
+ FL_SET(data, PROC_T4);
break;
default:
if (ruby_safe_level > 4) {
- FL_SET(data, BLOCK_TMAX);
+ FL_SET(data, PROC_TMAX);
}
break;
}
@@ -6802,16 +6801,16 @@ block_save_safe_level(data)
}
static int
-block_get_safe_level(data)
+proc_get_safe_level(data)
VALUE data;
{
if (OBJ_TAINTED(data)) {
- switch (RBASIC(data)->flags & BLOCK_TMASK) {
- case BLOCK_T3:
+ switch (RBASIC(data)->flags & PROC_TMASK) {
+ case PROC_T3:
return 3;
- case BLOCK_T4:
+ case PROC_T4:
return 4;
- case BLOCK_TMAX:
+ case PROC_TMAX:
return 5;
}
return 3;
@@ -6820,16 +6819,16 @@ block_get_safe_level(data)
}
static void
-block_set_safe_level(data)
+proc_set_safe_level(data)
VALUE data;
{
if (OBJ_TAINTED(data)) {
- ruby_safe_level = block_get_safe_level(data);
+ ruby_safe_level = proc_get_safe_level(data);
}
}
static VALUE
-block_alloc(klass, proc)
+proc_alloc(klass, proc)
VALUE klass;
int proc;
{
@@ -6871,9 +6870,9 @@ block_alloc(klass, proc)
}
}
scope_dup(data->scope);
- block_save_safe_level(block);
+ proc_save_safe_level(block);
if (proc) {
- data->flags |= BLOCK_PROC;
+ data->flags |= BLOCK_LAMBDA;
}
else {
ruby_block->block_obj = block;
@@ -6883,39 +6882,34 @@ block_alloc(klass, proc)
}
static VALUE
-block_s_new(argc, argv, klass)
+proc_s_new(argc, argv, klass)
int argc;
VALUE *argv;
VALUE klass;
{
- VALUE block = block_alloc(klass, Qfalse);
+ VALUE block = proc_alloc(klass, Qfalse);
rb_obj_call_init(block, argc, argv);
return block;
}
VALUE
-rb_block_new()
+rb_block_proc()
{
- return block_alloc(rb_cBlock, Qfalse);
+ return proc_alloc(rb_cProc, Qfalse);
}
-static VALUE
-proc_s_new(argc, argv, klass)
- int argc;
- VALUE *argv;
- VALUE klass;
+VALUE
+rb_f_lambda()
{
- VALUE block = block_alloc(klass, Qtrue);
-
- rb_obj_call_init(block, argc, argv);
- return block;
+ rb_warn("rb_f_lambda() is deprecated; use rb_block_proc() instead");
+ return proc_alloc(rb_cProc, Qtrue);
}
-VALUE
-rb_f_lambda()
+static VALUE
+proc_lambda()
{
- return block_alloc(rb_cProc, Qtrue);
+ return proc_alloc(rb_cProc, Qtrue);
}
static int
@@ -6933,8 +6927,8 @@ block_orphan(data)
}
static VALUE
-block_invoke(block, args, self, klass)
- VALUE block, args; /* OK */
+proc_invoke(proc, args, self, klass)
+ VALUE proc, args; /* OK */
VALUE self, klass;
{
struct BLOCK * volatile old_block;
@@ -6950,13 +6944,13 @@ block_invoke(block, args, self, klass)
if (rb_block_given_p() && ruby_frame->last_func) {
rb_warning("block for %s#%s is useless",
- rb_obj_classname(block),
+ rb_obj_classname(proc),
rb_id2name(ruby_frame->last_func));
}
- Data_Get_Struct(block, struct BLOCK, data);
+ Data_Get_Struct(proc, struct BLOCK, data);
orphan = block_orphan(data);
- pcall = data->flags & BLOCK_PROC;
+ pcall = data->flags & BLOCK_LAMBDA;
ruby_wrapper = data->wrapper;
ruby_dyna_vars = data->dyna_vars;
@@ -6972,7 +6966,7 @@ block_invoke(block, args, self, klass)
PUSH_TAG(PROT_NONE);
state = EXEC_TAG();
if (state == 0) {
- block_set_safe_level(block);
+ proc_set_safe_level(proc);
result = rb_yield_0(args, self, self!=Qundef?CLASS_OF(self):0, pcall, Qtrue);
}
POP_TAG();
@@ -6996,22 +6990,20 @@ block_invoke(block, args, self, klass)
}
/* fall through */
case TAG_BREAK:
+ case TAG_RETURN:
if (pcall) {
result = prot_tag->retval;
}
- else if (orphan) {
- localjump_error("break from block-closure", prot_tag->retval, state);
+ else if (orphan) { /* orphan block */
+ localjump_error("%s from block-closure",
+ state == TAG_BREAK ? "break" : "return",
+ prot_tag->retval, state);
}
else {
ruby_block->tag->dst = incoming_state;
JUMP_TAG(incoming_state);
}
break;
- case TAG_RETURN:
- if (orphan) { /* orphan block */
- localjump_error("return from block-closure", prot_tag->retval, state);
- }
- /* fall through */
default:
JUMP_TAG(state);
}
@@ -7019,24 +7011,24 @@ block_invoke(block, args, self, klass)
}
static VALUE
-block_call(block, args)
- VALUE block, args; /* OK */
+proc_call(proc, args)
+ VALUE proc, args; /* OK */
{
- return block_invoke(block, args, Qundef, 0);
+ return proc_invoke(proc, args, Qundef, 0);
}
static VALUE bmcall _((VALUE, VALUE));
static VALUE method_arity _((VALUE));
static VALUE
-block_arity(block)
- VALUE block;
+proc_arity(proc)
+ VALUE proc;
{
struct BLOCK *data;
NODE *list;
int n;
- Data_Get_Struct(block, struct BLOCK, data);
+ Data_Get_Struct(proc, struct BLOCK, data);
if (data->var == 0) {
if (data->body && nd_type(data->body) == NODE_IFUNC &&
data->body->nd_cfnc == bmcall) {
@@ -7062,7 +7054,7 @@ block_arity(block)
}
static VALUE
-block_eq(self, other)
+proc_eq(self, other)
VALUE self, other;
{
struct BLOCK *data, *data2;
@@ -7078,7 +7070,7 @@ block_eq(self, other)
}
static VALUE
-block_to_s(self, other)
+proc_to_s(self, other)
VALUE self, other;
{
struct BLOCK *data;
@@ -7106,20 +7098,20 @@ block_to_s(self, other)
}
static VALUE
-block_to_self(self)
+proc_to_self(self)
VALUE self;
{
return self;
}
static VALUE
-block_binding(block)
- VALUE block;
+proc_binding(proc)
+ VALUE proc;
{
struct BLOCK *orig, *data;
VALUE bind;
- Data_Get_Struct(block, struct BLOCK, orig);
+ Data_Get_Struct(proc, struct BLOCK, orig);
bind = Data_Make_Struct(rb_cBinding,struct BLOCK,blk_mark,blk_free,data);
MEMCPY(data, orig, struct BLOCK, 1);
frame_dup(&data->frame);
@@ -7156,7 +7148,7 @@ block_pass(self, node)
return result;
}
if (!rb_obj_is_block(block)) {
- b = rb_check_convert_type(block, T_DATA, "Block", "to_block");
+ b = rb_check_convert_type(block, T_DATA, "Block", "to_proc");
if (!rb_obj_is_block(b)) {
rb_raise(rb_eTypeError, "wrong argument type %s (expected Block)",
rb_obj_classname(block));
@@ -7165,7 +7157,7 @@ block_pass(self, node)
}
if (ruby_safe_level >= 1 && OBJ_TAINTED(block)) {
- if (ruby_safe_level > block_get_safe_level(block)) {
+ if (ruby_safe_level > proc_get_safe_level(block)) {
rb_raise(rb_eSecurityError, "Insecure: tainted block value");
}
}
@@ -7185,7 +7177,7 @@ block_pass(self, node)
PUSH_TAG(PROT_NONE);
state = EXEC_TAG();
if (state == 0) {
- block_set_safe_level(block);
+ proc_set_safe_level(block);
if (safe > ruby_safe_level)
ruby_safe_level = safe;
result = rb_eval(self, node->nd_iter);
@@ -7446,7 +7438,7 @@ method_arity(method)
return INT2FIX(0);
case NODE_BMETHOD:
case NODE_DMETHOD:
- return block_arity(method);
+ return proc_arity(method);
default:
body = body->nd_next; /* skip NODE_SCOPE */
if (nd_type(body) == NODE_BLOCK)
@@ -7508,7 +7500,7 @@ method_inspect(method)
}
static VALUE
-mblock(method)
+mproc(method)
VALUE method;
{
VALUE proc;
@@ -7516,7 +7508,7 @@ mblock(method)
/* emulate ruby's method call */
PUSH_ITER(ITER_CUR);
PUSH_FRAME();
- proc = rb_block_new();
+ proc = rb_block_proc();
POP_FRAME();
POP_ITER();
@@ -7548,22 +7540,14 @@ rb_proc_new(func, val)
VALUE (*func)(ANYARGS); /* VALUE yieldarg[, VALUE procarg] */
VALUE val;
{
- return rb_iterate((VALUE(*)_((VALUE)))mblock, 0, func, val);
-}
-
-static VALUE
-method_block(method)
- VALUE method;
-{
- return rb_iterate((VALUE(*)_((VALUE)))mblock, method, bmcall, method);
+ return rb_iterate((VALUE(*)_((VALUE)))mproc, 0, func, val);
}
static VALUE
method_proc(method)
VALUE method;
{
- rb_warn("Method#to_proc is deprecated; use Method#to_block");
- return method_block(method);
+ return rb_iterate((VALUE(*)_((VALUE)))mproc, method, bmcall, method);
}
static VALUE
@@ -7589,7 +7573,7 @@ rb_mod_define_method(argc, argv, mod)
if (argc == 1) {
id = rb_to_id(argv[0]);
- body = rb_f_lambda();
+ body = proc_lambda();
}
else if (argc == 2) {
id = rb_to_id(argv[0]);
@@ -7608,7 +7592,7 @@ rb_mod_define_method(argc, argv, mod)
else if (RDATA(body)->dmark == (RUBY_DATA_FUNC)blk_mark) {
struct BLOCK *block;
- body = block_clone(body);
+ body = proc_clone(body);
Data_Get_Struct(body, struct BLOCK, block);
block->frame.last_func = id;
block->frame.orig_func = id;
@@ -7647,28 +7631,27 @@ Init_Proc()
sysstack_error = rb_exc_new2(rb_eSysStackError, "stack level too deep");
rb_global_variable(&sysstack_error);
- rb_cBlock = rb_define_class("Block", rb_cObject);
- rb_undef_alloc_func(rb_cBlock);
- rb_define_singleton_method(rb_cBlock, "new", block_s_new, -1);
+ rb_cProc = rb_define_class("Proc", rb_cObject);
+ rb_cBlock = rb_cProc;
+ rb_undef_alloc_func(rb_cProc);
+ rb_define_singleton_method(rb_cProc, "new", proc_s_new, -1);
- rb_define_method(rb_cBlock, "clone", block_clone, 0);
- rb_define_method(rb_cBlock, "call", block_call, -2);
- rb_define_method(rb_cBlock, "arity", block_arity, 0);
- rb_define_method(rb_cBlock, "[]", block_call, -2);
- rb_define_method(rb_cBlock, "==", block_eq, 1);
- rb_define_method(rb_cBlock, "to_s", block_to_s, 0);
- rb_define_method(rb_cBlock, "to_block", block_to_self, 0);
- rb_define_method(rb_cBlock, "binding", block_binding, 0);
+ rb_define_method(rb_cProc, "clone", proc_clone, 0);
+ rb_define_method(rb_cProc, "call", proc_call, -2);
+ rb_define_method(rb_cProc, "arity", proc_arity, 0);
+ rb_define_method(rb_cProc, "[]", proc_call, -2);
+ rb_define_method(rb_cProc, "==", proc_eq, 1);
+ rb_define_method(rb_cProc, "to_s", proc_to_s, 0);
+ rb_define_method(rb_cProc, "to_proc", proc_to_self, 0);
+ rb_define_method(rb_cProc, "binding", proc_binding, 0);
- rb_cProc = rb_define_class("Proc", rb_cBlock);
- rb_define_singleton_method(rb_cProc, "new", proc_s_new, -1);
- rb_define_global_function("proc", rb_f_lambda, 0);
- rb_define_global_function("lambda", rb_f_lambda, 0);
+ rb_define_global_function("proc", proc_lambda, 0);
+ rb_define_global_function("lambda", proc_lambda, 0);
rb_cBinding = rb_define_class("Binding", rb_cObject);
rb_undef_alloc_func(rb_cBinding);
rb_undef_method(CLASS_OF(rb_cBinding), "new");
- rb_define_method(rb_cBinding, "clone", block_clone, 0);
+ rb_define_method(rb_cBinding, "clone", proc_clone, 0);
rb_define_global_function("binding", rb_f_binding, 0);
rb_cMethod = rb_define_class("Method", rb_cObject);
@@ -7681,7 +7664,6 @@ Init_Proc()
rb_define_method(rb_cMethod, "arity", method_arity, 0);
rb_define_method(rb_cMethod, "inspect", method_inspect, 0);
rb_define_method(rb_cMethod, "to_s", method_inspect, 0);
- rb_define_method(rb_cMethod, "to_block", method_block, 0);
rb_define_method(rb_cMethod, "to_proc", method_proc, 0);
rb_define_method(rb_cMethod, "unbind", method_unbind, 0);
rb_define_method(rb_mKernel, "method", rb_obj_method, 1);
diff --git a/ext/tk/lib/tk.rb b/ext/tk/lib/tk.rb
index ec1ee8f8c0..cefb87400a 100644
--- a/ext/tk/lib/tk.rb
+++ b/ext/tk/lib/tk.rb
@@ -443,11 +443,11 @@ module TkComm
private :install_bind, :tk_event_sequence,
:_bind_core, :_bind, :_bind_append, :_bind_remove, :_bindinfo
- def bind(tagOrClass, context, cmd=Block.new, args=nil)
+ def bind(tagOrClass, context, cmd=Proc.new, args=nil)
_bind(["bind", tagOrClass], context, cmd, args)
end
- def bind_append(tagOrClass, context, cmd=Block.new, args=nil)
+ def bind_append(tagOrClass, context, cmd=Proc.new, args=nil)
_bind_append(["bind", tagOrClass], context, cmd, args)
end
@@ -459,11 +459,11 @@ module TkComm
_bindinfo(['bind', tagOrClass], context)
end
- def bind_all(context, cmd=Block.new, args=nil)
+ def bind_all(context, cmd=Proc.new, args=nil)
_bind(['bind', 'all'], context, cmd, args)
end
- def bind_append_all(context, cmd=Block.new, args=nil)
+ def bind_append_all(context, cmd=Proc.new, args=nil)
_bind_append(['bind', 'all'], context, cmd, args)
end
@@ -515,7 +515,7 @@ module TkCore
fail TkCallbackContinue, "Tk callback returns 'continue' status"
end
- def after(ms, cmd=Block.new)
+ def after(ms, cmd=Proc.new)
myid = _curr_cmd_id
cmdid = install_cmd(cmd)
tk_call("after",ms,cmdid)
@@ -533,7 +533,7 @@ module TkCore
# end
end
- def after_idle(cmd=Block.new)
+ def after_idle(cmd=Proc.new)
myid = _curr_cmd_id
cmdid = install_cmd(cmd)
tk_call('after','idle',cmdid)
@@ -873,10 +873,10 @@ module Tk
end
module Scrollable
- def xscrollcommand(cmd=Block.new)
+ def xscrollcommand(cmd=Proc.new)
configure_cmd 'xscrollcommand', cmd
end
- def yscrollcommand(cmd=Block.new)
+ def yscrollcommand(cmd=Proc.new)
configure_cmd 'yscrollcommand', cmd
end
def xview(*index)
@@ -1105,11 +1105,11 @@ else
end
module TkBindCore
- def bind(context, cmd=Block.new, args=nil)
+ def bind(context, cmd=Proc.new, args=nil)
Tk.bind(to_eval, context, cmd, args)
end
- def bind_append(context, cmd=Block.new, args=nil)
+ def bind_append(context, cmd=Proc.new, args=nil)
Tk.bind_append(to_eval, context, cmd, args)
end
@@ -2163,7 +2163,7 @@ module TkOption
proc_str = TkOption.get(self::CARRIER, id.id2name, '')
proc_str = '{' + proc_str + '}' unless /\A\{.*\}\Z/ =~ proc_str
proc_str = __check_proc_string__(proc_str)
- res_proc = eval 'Block.new' + proc_str
+ res_proc = eval 'Proc.new' + proc_str
self::METHOD_TBL[id] = res_proc
end
proc{
@@ -2857,7 +2857,7 @@ class TkWindow<TkObject
self
end
- def command(cmd=Block.new)
+ def command(cmd=Proc.new)
configure_cmd 'command', cmd
end
@@ -3475,10 +3475,10 @@ class TkMenu<TkWindow
def postcascade(index)
tk_send 'postcascade', index
end
- def postcommand(cmd=Block.new)
+ def postcommand(cmd=Proc.new)
configure_cmd 'postcommand', cmd
end
- def tearoffcommand(cmd=Block.new)
+ def tearoffcommand(cmd=Proc.new)
configure_cmd 'tearoffcommand', cmd
end
def menutype(index)
diff --git a/ext/tk/lib/tkcanvas.rb b/ext/tk/lib/tkcanvas.rb
index 7f0fba13ec..4a5e4b45bb 100644
--- a/ext/tk/lib/tkcanvas.rb
+++ b/ext/tk/lib/tkcanvas.rb
@@ -81,11 +81,11 @@ class TkCanvas<TkWindow
list(tk_send('bbox', tagid(tagOrId), *tags.collect{|t| tagid(t)}))
end
- def itembind(tag, context, cmd=Block.new, args=nil)
+ def itembind(tag, context, cmd=Proc.new, args=nil)
_bind([path, "bind", tagid(tag)], context, cmd, args)
end
- def itembind_append(tag, context, cmd=Block.new, args=nil)
+ def itembind_append(tag, context, cmd=Proc.new, args=nil)
_bind_append([path, "bind", tagid(tag)], context, cmd, args)
end
@@ -346,7 +346,7 @@ module TkcTagAccess
@c.bbox(@id)
end
- def bind(seq, cmd=Block.new, args=nil)
+ def bind(seq, cmd=Proc.new, args=nil)
@c.itembind @id, seq, cmd, args
end
diff --git a/ext/tk/lib/tkentry.rb b/ext/tk/lib/tkentry.rb
index f95fdf340d..2772dfd676 100644
--- a/ext/tk/lib/tkentry.rb
+++ b/ext/tk/lib/tkentry.rb
@@ -38,7 +38,7 @@ class TkEntry<TkLabel
attr :widget
end
- def initialize(cmd = Block.new, args=nil)
+ def initialize(cmd = Proc.new, args=nil)
if args
@id = install_cmd(proc{|*arg|
TkUtil.eval_cmd cmd, *arg
diff --git a/ext/tk/lib/tktext.rb b/ext/tk/lib/tktext.rb
index 2db9a22bdf..62747be0bd 100644
--- a/ext/tk/lib/tktext.rb
+++ b/ext/tk/lib/tktext.rb
@@ -172,11 +172,11 @@ class TkText<TkTextWin
tk_send 'tag', 'add', tag, index1, index2
end
- def tag_bind(tag, seq, cmd=Block.new, args=nil)
+ def tag_bind(tag, seq, cmd=Proc.new, args=nil)
_bind(['tag', 'bind', tag], seq, cmd, args)
end
- def tag_bind_append(tag, seq, cmd=Block.new, args=nil)
+ def tag_bind_append(tag, seq, cmd=Proc.new, args=nil)
_bind_append(['tag', 'bind', tag], seq, cmd, args)
end
@@ -663,11 +663,11 @@ class TkTextTag<TkObject
@t.tag_configinfo @id, key
end
- def bind(seq, cmd=Block.new, args=nil)
+ def bind(seq, cmd=Proc.new, args=nil)
_bind([@t.path, 'tag', 'bind', @id], seq, cmd, args)
end
- def bind_append(seq, cmd=Block.new, args=nil)
+ def bind_append(seq, cmd=Proc.new, args=nil)
_bind_append([@t.path, 'tag', 'bind', @id], seq, cmd, args)
end
diff --git a/gc.c b/gc.c
index a34a3238a2..3c06bfc5da 100644
--- a/gc.c
+++ b/gc.c
@@ -1469,7 +1469,7 @@ define_final(argc, argv, os)
rb_scan_args(argc, argv, "11", &obj, &block);
if (argc == 1) {
- block = rb_block_new();
+ block = rb_block_proc();
}
else if (!rb_respond_to(block, rb_intern("call"))) {
rb_raise(rb_eArgError, "wrong type argument %s (should be callable)",
diff --git a/hash.c b/hash.c
index 26a4fe5ace..03318c31a0 100644
--- a/hash.c
+++ b/hash.c
@@ -209,7 +209,7 @@ rb_hash_initialize(argc, argv, hash)
if (argc > 0) {
rb_raise(rb_eArgError, "wrong number of arguments");
}
- RHASH(hash)->ifnone = rb_block_new();
+ RHASH(hash)->ifnone = rb_block_proc();
FL_SET(hash, HASH_PROC_DEFAULT);
}
else {
diff --git a/intern.h b/intern.h
index a93f5e61cf..5fddb41ac8 100644
--- a/intern.h
+++ b/intern.h
@@ -176,7 +176,7 @@ void rb_provide _((const char*));
VALUE rb_f_require _((VALUE, VALUE));
void rb_obj_call_init _((VALUE, int, VALUE*));
VALUE rb_class_new_instance _((int, VALUE*, VALUE));
-VALUE rb_block_new _((void));
+VALUE rb_block_proc _((void));
VALUE rb_f_lambda _((void));
VALUE rb_proc_new _((VALUE (*)(ANYARGS/* VALUE yieldarg[, VALUE procarg] */), VALUE));
VALUE rb_protect _((VALUE (*)(VALUE), VALUE, int*));
diff --git a/lib/irb/ruby-lex.rb b/lib/irb/ruby-lex.rb
index 4b58ba6fd5..3b62ef8676 100644
--- a/lib/irb/ruby-lex.rb
+++ b/lib/irb/ruby-lex.rb
@@ -74,7 +74,7 @@ class RubyLex
elsif block_given?
@input = block
else
- @input = Block.new{@io.gets}
+ @input = Proc.new{@io.gets}
end
end
@@ -188,7 +188,7 @@ class RubyLex
if p.respond_to?(:call)
@prompt = p
else
- @prompt = Block.new{print p}
+ @prompt = Proc.new{print p}
end
end
diff --git a/lib/mkmf.rb b/lib/mkmf.rb
index 32e76d7dca..b0b3817b54 100644
--- a/lib/mkmf.rb
+++ b/lib/mkmf.rb
@@ -833,7 +833,7 @@ Config::CONFIG["topdir"] = CONFIG["topdir"] =
$configure_args["--topdir"] ||= $curdir
$ruby = arg_config("--ruby", CONFIG["ruby_install_name"])
-split = Shellwords.method(:shellwords).to_block
+split = Shellwords.method(:shellwords).to_proc
EXPORT_PREFIX = config_string('EXPORT_PREFIX') {|s| s.strip}
diff --git a/lib/net/imap.rb b/lib/net/imap.rb
index 1007f2bdf6..2cbb408168 100644
--- a/lib/net/imap.rb
+++ b/lib/net/imap.rb
@@ -263,7 +263,7 @@ Object
If this mailbox exists, an array containing objects of
((<Net::IMAP::MailboxACLItem>)) will be returned.
-: add_response_handler(handler = Block.new)
+: add_response_handler(handler = Proc.new)
Adds a response handler.
ex).
@@ -1047,7 +1047,7 @@ module Net
return sort_internal("UID SORT", sort_keys, search_keys, charset)
end
- def add_response_handler(handler = Block.new)
+ def add_response_handler(handler = Proc.new)
@response_handlers.push(handler)
end
diff --git a/lib/optparse.rb b/lib/optparse.rb
index 7a2cfc49c9..50d72f8a2e 100644
--- a/lib/optparse.rb
+++ b/lib/optparse.rb
@@ -167,7 +167,7 @@ Individual switch class.
=end #'#"#`#
def initialize(pattern = nil, conv = nil,
short = nil, long = nil, arg = nil,
- desc = ([] if short or long), block = Block.new)
+ desc = ([] if short or long), block = Proc.new)
@pattern, @conv, @short, @long, @arg, @desc, @block =
pattern, conv, short, long, arg, desc, block
end
@@ -414,7 +414,7 @@ summary feature.
pat = t if t.respond_to?(:match)
end
unless block
- block = pat.method(:convert).to_block if pat.respond_to?(:convert)
+ block = pat.method(:convert).to_proc if pat.respond_to?(:convert)
end
@atype[t] = [pat, block]
end
@@ -482,7 +482,7 @@ summary feature.
searching list.
: ((|k|))
searching key.
- : (({Block}))
+ : (({block}))
yielded with the found value when succeeded.
=end #'#"#`#
def search(id, key)
@@ -503,7 +503,7 @@ summary feature.
searching key.
: ((|*pat|))
optional pattern for completion.
- : (({Block}))
+ : (({block}))
yielded with the found value when succeeded.
=end #'#"#`#
def complete(id, opt, *pat, &block)
@@ -634,7 +634,7 @@ Default options, which never appear in option summary.
summary width.
: ((|indent|))
summary indent.
- : (({Block}))
+ : (({block}))
to be evaluated in the new instance context.
=end #'#"#`#
def self.with(*args, &block)
@@ -670,7 +670,7 @@ Default options, which never appear in option summary.
summary width.
: ((|indent|))
summary indent.
- : (({Block}))
+ : (({block}))
to be evaluated in the new instance context.
=end #'#"#`#
def initialize(banner = nil, width = 32, indent = ' ' * 4)
@@ -709,7 +709,7 @@ Default options, which never appear in option summary.
argument class specifier, any object including Class.
: ((|pat|))
pattern for argument, defaulted to ((|t|)) if it respond to (({match})).
- : (({Block}))
+ : (({block}))
receives argument string and should be convert to desired class.
=end #'#"#`#
def accept(*args, &blk) top.accept(*args, &blk) end
@@ -842,7 +842,7 @@ Default options, which never appear in option summary.
maximum length allowed for left side. Defaulted to (({((|width|)) - 1}))
: ((|indent|))
indentation. Defaulted to ((|@summary_indent|))
- : (({Block}))
+ : (({block}))
yields with each line if called as iterator.
=end #'#"#`#
def summarize(to = [], width = @summary_width, max = width - 1, indent = @summary_indent, &blk)
@@ -898,7 +898,7 @@ Default options, which never appear in option summary.
argument style and description.
: "description", ...
((*description*)) for this option.
- : (({Block}))
+ : (({block}))
((*handler*)) to convert option argument to arbitrary (({Class})).
=end #'#"#`#
=begin private
@@ -949,7 +949,7 @@ Default options, which never appear in option summary.
# directly specified pattern(any object possible to match)
if !(String === o) and o.respond_to?(:match)
pattern = notwice(o, pattern, 'pattern')
- conv = (pattern.method(:convert).to_block if pattern.respond_to?(:convert))
+ conv = (pattern.method(:convert).to_proc if pattern.respond_to?(:convert))
next
end
@@ -962,7 +962,7 @@ Default options, which never appear in option summary.
when CompletingHash
when nil
pattern = CompletingHash.new
- conv = (pattern.method(:convert).to_block if pattern.respond_to?(:convert))
+ conv = (pattern.method(:convert).to_proc if pattern.respond_to?(:convert))
else
raise ArgumentError, "argument pattern given twice"
end
@@ -1107,7 +1107,7 @@ Default options, which never appear in option summary.
:Parameters:
: ((|argv|))
command line arguments to be parsed.
- : (({Block}))
+ : (({block}))
called with each non-option argument.
=end #'#"#`#
def order(*argv, &block) order!(argv, &block) end
@@ -1233,7 +1233,7 @@ Default options, which never appear in option summary.
called method in each elements of (({stack}))s.
: ((|*args|))
passed to ((|id|)).
- : (({Block}))
+ : (({block}))
passed to ((|id|)).
=end #'#"#`#
def visit(id, *args, &block)
@@ -1254,7 +1254,7 @@ Default options, which never appear in option summary.
searching table.
: ((|k|))
searching key.
- : (({Block}))
+ : (({block}))
yielded with the found value when succeeded.
=end #'#"#`#
def search(id, k)
@@ -1276,7 +1276,7 @@ Default options, which never appear in option summary.
searching key.
: ((|*pat|))
optional pattern for completion.
- : (({Block}))
+ : (({block}))
yielded with the found value when succeeded.
=end #'#"#`#
def complete(typ, opt, *pat)
diff --git a/lib/rexml/parsers/sax2parser.rb b/lib/rexml/parsers/sax2parser.rb
index 4cddc4806d..2280b983a3 100644
--- a/lib/rexml/parsers/sax2parser.rb
+++ b/lib/rexml/parsers/sax2parser.rb
@@ -185,7 +185,7 @@ module REXML
end
def add( pair )
- if pair[-1].kind_of? Proc or (defined? Block and pair[-1].kind_of? Block)
+ if pair[-1].respond_to? :call
@procs << pair unless @procs.include? pair
else
@listeners << pair unless @listeners.include? pair
diff --git a/lib/tracer.rb b/lib/tracer.rb
index 673290c2ab..3ccf1b5017 100644
--- a/lib/tracer.rb
+++ b/lib/tracer.rb
@@ -62,7 +62,7 @@ class Tracer
off
end
else
- set_trace_func method(:trace_func).to_block
+ set_trace_func method(:trace_func).to_proc
stdout.print "Trace on\n" if Tracer.verbose?
end
end
diff --git a/sample/test.rb b/sample/test.rb
index 62e9a3b7e9..6b514a20e3 100644
--- a/sample/test.rb
+++ b/sample/test.rb
@@ -928,9 +928,9 @@ class IterTest
a
end
end
-test_ok(IterTest.new(nil).method(:f).to_block.call([1]) == [1])
+test_ok(IterTest.new(nil).method(:f).to_proc.call([1]) == [1])
m = /\w+/.match("abc")
-test_ok(IterTest.new(nil).method(:f).to_block.call([m]) == [m])
+test_ok(IterTest.new(nil).method(:f).to_proc.call([m]) == [m])
IterTest.new([0]).each0 {|x| test_ok(x == 0)}
IterTest.new([1]).each1 {|x| test_ok(x == 1)}
@@ -977,9 +977,7 @@ end
test_ok(C.new.collect{|n| n} == [1,2,3])
-test_ok(Proc < Block)
test_ok(Proc == lambda{}.class)
-test_ok(Proc == proc{}.class)
test_ok(Proc == Proc.new{}.class)
lambda{|a|test_ok(a==1)}.call(1)
def block_test(klass, &block)
@@ -987,7 +985,7 @@ def block_test(klass, &block)
end
block_test(NilClass)
-block_test(Block){}
+block_test(Proc){}
def argument_test(state, proc, *args)
x = state
@@ -1009,7 +1007,7 @@ def get_block(&block)
block
end
-test_ok(Block == get_block{}.class)
+test_ok(Proc == get_block{}.class)
argument_test(true, get_block{||})
argument_test(true, get_block{||}, 1)
argument_test(true, get_block{|a,|}, 1)
@@ -1022,19 +1020,19 @@ argument_test(true, get_block(&lambda{|a,|}),1)
argument_test(false, get_block(&lambda{|a,|}),1,2)
block = get_block{11}
-proc = lambda{44}
-test_ok(block.class == Block)
-test_ok(proc.class == Proc)
-test_ok(block.to_block.class == Block)
-test_ok(proc.to_block.class == Proc)
+test_ok(block.class == Proc)
+test_ok(block.to_proc.class == Proc)
test_ok(block.clone.call == 11)
-test_ok(proc.clone.call == 44)
+test_ok(get_block(&block).class == Proc)
-test_ok(get_block(&block).class == Block)
-test_ok(get_block(&proc).class == Block)
+lambda = lambda{44}
+test_ok(lambda.class == Proc)
+test_ok(lambda.to_proc.class == Proc)
+test_ok(lambda.clone.call == 44)
+test_ok(get_block(&lambda).class == Proc)
-test_ok(Block.new{|a,| a}.call(1,2,3) == 1)
-argument_test(false, Proc.new{|a,| p a}, 1,2)
+test_ok(Proc.new{|a,| a}.call(1,2,3) == 1)
+argument_test(true, Proc.new{|a,|}, 1,2)
def ljump_test(state, proc, *args)
x = state
@@ -1050,7 +1048,7 @@ ljump_test(false, get_block{break})
ljump_test(true, lambda{break})
test_ok(block.arity == -1)
-test_ok(proc.arity == -1)
+test_ok(lambda.arity == -1)
test_ok(lambda{||}.arity == 0)
test_ok(lambda{|a|}.arity == 1)
test_ok(lambda{|a,|}.arity == 1)
@@ -1058,7 +1056,7 @@ test_ok(lambda{|a,b|}.arity == 2)
def marity_test(m)
method = method(m)
- test_ok(method.arity == method.to_block.arity)
+ test_ok(method.arity == method.to_proc.arity)
end
marity_test(:test_ok)
marity_test(:marity_test)
diff --git a/signal.c b/signal.c
index 719fb4cb9f..d4bdb2320f 100644
--- a/signal.c
+++ b/signal.c
@@ -650,7 +650,7 @@ sig_trap(argc, argv)
arg.sig = argv[0];
if (argc == 1) {
- arg.cmd = rb_block_new();
+ arg.cmd = rb_block_proc();
}
else if (argc == 2) {
arg.cmd = argv[1];
diff --git a/variable.c b/variable.c
index 3d55882954..f0ace3afb1 100644
--- a/variable.c
+++ b/variable.c
@@ -540,7 +540,7 @@ rb_f_trace_var(argc, argv)
rb_secure(4);
if (rb_scan_args(argc, argv, "11", &var, &cmd) == 1) {
- cmd = rb_block_new();
+ cmd = rb_block_proc();
}
if (NIL_P(cmd)) {
return rb_f_untrace_var(argc, argv);