aboutsummaryrefslogtreecommitdiffstats
path: root/README.EXT
diff options
context:
space:
mode:
authorknu <knu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-02-16 05:54:17 +0000
committerknu <knu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-02-16 05:54:17 +0000
commit2b206be6acca2b0e5c2894860f578e087a4e3c5b (patch)
tree9a078c3124e6fd798a797080e4d9fa37072d03ed /README.EXT
parent2a3d58d6924767433d296df187fc68e1d8485f0c (diff)
downloadruby-2b206be6acca2b0e5c2894860f578e087a4e3c5b.tar.gz
Improve documentation of rb_scan_args().
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22335 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'README.EXT')
-rw-r--r--README.EXT27
1 files changed, 24 insertions, 3 deletions
diff --git a/README.EXT b/README.EXT
index b720fba3a4..2d02708255 100644
--- a/README.EXT
+++ b/README.EXT
@@ -678,15 +678,36 @@ argument is the C array of the method arguments, and the third
argument is the receiver of the method.
You can use the function rb_scan_args() to check and retrieve the
-arguments. For example, "11" means that the method requires at least one
-argument, and at most receives two arguments.
+arguments. The third argument is a string that specifies how to
+capture method arguments and assign them to the following variable
+references. The format can be described in ABNF as follows:
+
+--
+scan-arg-spec := param-arg-spec [block-arg-spec]
+
+param-arg-spec := pre-arg-spec [post-arg-spec] / post-arg-spec
+pre-arg-spec := num-of-leading-mandatory-args [num-of-optional-args]
+post-arg-spec := sym-for-variable-length-args
+block-arg-spec := sym-for-block-arg
+
+num-of-leading-mandatory-args := DIGIT ; -- the number of the leading mandatory arguments
+num-of-optional-args := DIGIT ; -- the number of the following optional arguments
+sym-for-variable-length-args := "*" ; -- indicates that the following variable length
+ ; arguments are captured as a Ruby array
+sym-for-block-arg := "&" ; -- indicates that the iterator block should be
+ ; captured if given
+--
+
+For example, "11" means that the method requires at least one
+argument, and at most receives two arguments. For omitted arguments,
+variables are set to Qnil.
Methods with an arbitrary number of arguments can receive arguments
by Ruby's array, like this:
--
static VALUE
-fdbm_indexes(VALUE obj, VALUE args)
+thread_initialize(VALUE thread, VALUE args)
{
:
}