[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

[DOCBUG] Proc#arity

Joel VanderWerf

11/14/2004 7:22:00 AM


An inconsistency in the docs for Proc#arity ? Here's what ri says:

arguments. A +proc+ with no argument declarations returns -1, as it
can accept (and ignore) an arbitrary number of parameters.

Proc.new {}.arity #=> 0

$ ruby -v
ruby 1.9.0 (2004-11-08) [i686-linux]


6 Answers

Mauricio Fernández

11/14/2004 9:19:00 AM

0

On Sun, Nov 14, 2004 at 04:22:24PM +0900, Joel VanderWerf wrote:
>
> An inconsistency in the docs for Proc#arity ? Here's what ri says:
>
> arguments. A +proc+ with no argument declarations returns -1, as it
> can accept (and ignore) an arbitrary number of parameters.
>
> Proc.new {}.arity #=> 0
>
> $ ruby -v
> ruby 1.9.0 (2004-11-08) [i686-linux]


Thu Mar 18 16:22:38 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
[...]

* eval.c (proc_arity): arity is now defined as number of
parameters that would not be ignored. i.e. Proc.new{}.arity
returns zero. update test suites too.


http://rcrchive.net/rc...

--
Hassle-free packages for Ruby?
RPA is available from http://www.rubyar...


Yukihiro Matsumoto

11/14/2004 9:44:00 AM

0

Hi,

In message "Re: [DOCBUG] Proc#arity"
on Sun, 14 Nov 2004 18:19:25 +0900, Mauricio Fernández <batsman.geo@yahoo.com> writes:

|> An inconsistency in the docs for Proc#arity ? Here's what ri says:
|>
|> arguments. A +proc+ with no argument declarations returns -1, as it
|> can accept (and ignore) an arbitrary number of parameters.

| * eval.c (proc_arity): arity is now defined as number of
| parameters that would not be ignored. i.e. Proc.new{}.arity
| returns zero. update test suites too.

And lambda{}.call(1) should have made to raise exception. I will fix
this. Could somebody update the document?

matz.



Sam Roberts

11/14/2004 4:29:00 PM

0

Quoteing matz@ruby-lang.org, on Sun, Nov 14, 2004 at 06:43:32PM +0900:
> In message "Re: [DOCBUG] Proc#arity"
> on Sun, 14 Nov 2004 18:19:25 +0900, Mauricio Fernández <batsman.geo@yahoo.com> writes:
> |> An inconsistency in the docs for Proc#arity ? Here's what ri says:
> |>
> |> arguments. A +proc+ with no argument declarations returns -1, as it
> |> can accept (and ignore) an arbitrary number of parameters.
>
> | * eval.c (proc_arity): arity is now defined as number of
> | parameters that would not be ignored. i.e. Proc.new{}.arity
> | returns zero. update test suites too.
>
> And lambda{}.call(1) should have made to raise exception. I will fix
> this. Could somebody update the document?

If I understand this correctly, the docs should now say something like
the below?

Cheers,
Sam


Index: eval.c
===================================================================
RCS file: /src/ruby/eval.c,v
retrieving revision 1.616.2.68
diff -u -r1.616.2.68 eval.c
--- eval.c 12 Nov 2004 06:06:12 -0000 1.616.2.68
+++ eval.c 14 Nov 2004 16:26:35 -0000
@@ -8207,15 +8207,14 @@
* call-seq:
* prc.arity -> fixnum
*
- * Returns the number of arguments required by the block. If the block
+ * Returns the number of arguments that would not be ignored. If the block
* is declared to take no arguments, returns 0. If the block is known
* to take exactly n arguments, returns n. If the block has optional
* arguments, return -n-1, where n is the number of mandatory
- * arguments. A <code>proc</code> with no argument declarations
- * returns -1, as it can accept (and ignore) an arbitrary number of
- * parameters.
+ * arguments. A <code>proc</code> with no argument declarations
+ * is handled like a block declaring <code>||</code> as its arguments.
*
- * Proc.new {}.arity #=> -1
+ * Proc.new {}.arity #=> 0
* Proc.new {||}.arity #=> 0
* Proc.new {|a|}.arity #=> 1
* Proc.new {|a,b|}.arity #=> 2




Dave Thomas

11/14/2004 10:19:00 PM

0


On Nov 14, 2004, at 3:43, Yukihiro Matsumoto wrote:

> And lambda{}.call(1) should have made to raise exception. I will fix
> this. Could somebody update the document?

Matz:

The document is simply the comment before the method- :)


Cheers

Dave



Yukihiro Matsumoto

11/14/2004 11:11:00 PM

0

Hi,

In message "Re: [DOCBUG] Proc#arity"
on Mon, 15 Nov 2004 07:18:53 +0900, Dave Thomas <dave@pragprog.com> writes:

|> Could somebody update the document?
|
|Matz:
|
|The document is simply the comment before the method- :)

I know. I was just too lazy to make up "proper" statement.

matz.


Yukihiro Matsumoto

11/14/2004 11:53:00 PM

0

Hi,

In message "Re: [DOCBUG] Proc#arity"
on Mon, 15 Nov 2004 01:29:21 +0900, Sam Roberts <sroberts@uniserve.com> writes:

|If I understand this correctly, the docs should now say something like
|the below?

Thank you!

matz.