Forum: Ruby-dev value of def-expr

C4e88907313843cf07f6d85ba8162120?d=identicon&s=25 yhara (Yutaka HARA) (Guest)
on 2012-10-27 16:58
(Received via mailing list)
Issue #3753 has been updated by yhara (Yutaka HARA).

Description updated
Target version set to next minor


----------------------------------------
Feature #3753: value of def-expr
https://bugs.ruby-lang.org/issues/3753#change-31811

Author: usa (Usaku NAKAMURA)
Status: Assigned
Priority: Normal
Assignee: matz (Yukihiro Matsumoto)
Category: core
Target version: next minor


=begin
 RubyKaigi見てて思い出したのですが、def式はSymbolを返すようにしませんか?
 そうすると、

 class Foo
   private def foo()
     # ...
   end
 end

 などと書けるようになります。

 以下パッチ。
 Index: vm.c
 ===================================================================
 --- vm.c  (リビジョン 29124)
 +++ vm.c  (作業コピー)
 @@ -1893,7 +1893,7 @@ m_core_define_method(VALUE self, VALUE c
      REWIND_CFP({
    vm_define_method(GET_THREAD(), cbase, SYM2ID(sym), iseqval, 0,
rb_vm_cref());
      });
 -    return Qnil;
 +    return sym;
  }

  static VALUE
 @@ -1902,7 +1902,7 @@ m_core_define_singleton_method(VALUE sel
      REWIND_CFP({
    vm_define_method(GET_THREAD(), cbase, SYM2ID(sym), iseqval, 1,
rb_vm_cref());
      });
 -    return Qnil;
 +    return sym;
  }

  static VALUE
=end
This topic is locked and can not be replied to.