[前][次][番号順一覧][スレッド一覧]

ruby-changes:46034

From: usa <ko1@a...>
Date: Sun, 26 Mar 2017 02:08:10 +0900 (JST)
Subject: [ruby-changes:46034] usa:r58105 (ruby_2_2): merge revision(s) 57765: [Backport #13273]

usa	2017-03-26 02:08:06 +0900 (Sun, 26 Mar 2017)

  New Revision: 58105

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=58105

  Log:
    merge revision(s) 57765: [Backport #13273]
    
    proc.c: documentation for Proc#{call,yield,[]}
    
    * proc.c: [DOC] fix and improve docs for Proc#{call,yield,[]}:
    
      * change order of Document-method directives as workaround for an
        RDoc rendering problem where the documentation for Proc#call displays
        a "Document-method: []" code block.  [ruby-core:79887] [Bug #13273]
      * add missing call-seq and example for Proc#yield
      * remove pointless cross reference to Proc#yield
      * update description for handling of extra or missing arguments,
        improve examples and add cross reference to #lambda?

  Modified directories:
    branches/ruby_2_2/
  Modified files:
    branches/ruby_2_2/proc.c
    branches/ruby_2_2/version.h
Index: ruby_2_2/proc.c
===================================================================
--- ruby_2_2/proc.c	(revision 58104)
+++ ruby_2_2/proc.c	(revision 58105)
@@ -674,38 +674,42 @@ rb_block_clear_env_self(VALUE proc) https://github.com/ruby/ruby/blob/trunk/ruby_2_2/proc.c#L674
 /* CHECKME: are the argument checking semantics correct? */
 
 /*
+ *  Document-method: []
+ *  Document-method: call
+ *  Document-method: yield
+ *
  *  call-seq:
  *     prc.call(params,...)   -> obj
  *     prc[params,...]        -> obj
  *     prc.(params,...)       -> obj
+ *     prc.yield(params,...)  -> obj
  *
  *  Invokes the block, setting the block's parameters to the values in
  *  <i>params</i> using something close to method calling semantics.
- *  Generates a warning if multiple values are passed to a proc that
- *  expects just one (previously this silently converted the parameters
- *  to an array).  Note that prc.() invokes prc.call() with the parameters
- *  given.  It's a syntax sugar to hide "call".
+ *  Returns the value of the last expression evaluated in the block.
+ *
+ *     a_proc = Proc.new {|scalar, *values| values.map {|value| value*scalar } }
+ *     a_proc.call(9, 1, 2, 3)    #=> [9, 18, 27]
+ *     a_proc[9, 1, 2, 3]         #=> [9, 18, 27]
+ *     a_proc.(9, 1, 2, 3)        #=> [9, 18, 27]
+ *     a_proc.yield(9, 1, 2, 3)   #=> [9, 18, 27]
+ *
+ *  Note that <code>prc.()</code> invokes <code>prc.call()</code> with
+ *  the parameters given.  It's syntactic sugar to hide "call".
  *
  *  For procs created using <code>lambda</code> or <code>->()</code> an error
- *  is generated if the wrong number of parameters are passed to a Proc with
- *  multiple parameters.  For procs created using <code>Proc.new</code> or
- *  <code>Kernel.proc</code>, extra parameters are silently discarded.
- *
- *  Returns the value of the last expression evaluated in the block. See
- *  also <code>Proc#yield</code>.
- *
- *     a_proc = Proc.new {|a, *b| b.collect {|i| i*a }}
- *     a_proc.call(9, 1, 2, 3)   #=> [9, 18, 27]
- *     a_proc[9, 1, 2, 3]        #=> [9, 18, 27]
- *     a_proc = lambda {|a,b| a}
- *     a_proc.call(1,2,3)
- *
- *  <em>produces:</em>
- *
- *     prog.rb:4:in `block in <main>': wrong number of arguments (3 for 2) (ArgumentError)
- *     	from prog.rb:5:in `call'
- *     	from prog.rb:5:in `<main>'
+ *  is generated if the wrong number of parameters are passed to the proc.
+ *  For procs created using <code>Proc.new</code> or <code>Kernel.proc</code>,
+ *  extra parameters are silently discarded and missing parameters are
+ *  set to +nil+.
+ *
+ *     a_proc = proc {|a,b| [a,b] }
+ *     a_proc.call(1)   #=> [1, nil]
+ *
+ *     a_proc = lambda {|a,b| [a,b] }
+ *     a_proc.call(1)   # ArgumentError: wrong number of arguments (given 1, expected 2)
  *
+ *  See also Proc#lambda?.
  */
 
 static VALUE
Index: ruby_2_2/version.h
===================================================================
--- ruby_2_2/version.h	(revision 58104)
+++ ruby_2_2/version.h	(revision 58105)
@@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_2/version.h#L1
 #define RUBY_VERSION "2.2.7"
 #define RUBY_RELEASE_DATE "2017-03-26"
-#define RUBY_PATCHLEVEL 437
+#define RUBY_PATCHLEVEL 438
 
 #define RUBY_RELEASE_YEAR 2017
 #define RUBY_RELEASE_MONTH 3

Property changes on: ruby_2_2
___________________________________________________________________
Modified: svn:mergeinfo
   Merged /trunk:r57765


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]