* arity bug?
@ 2003-10-05 16:29 Christoph
2003-10-05 16:33 ` ts
0 siblings, 1 reply; 5+ messages in thread
From: Christoph @ 2003-10-05 16:29 UTC (permalink / raw
To: ruby-core
Hi,
the following (with (2003-09-18) [i386-mingw32]
and (2003-10-03) [i386-mswin32])
---
p proc {|| 13 }.arity # 0
p proc { 13 }.arity # -1
---
looks like a bug to me?
/Christoph
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: arity bug?
2003-10-05 16:29 arity bug? Christoph
@ 2003-10-05 16:33 ` ts
2003-10-05 16:55 ` Christoph
0 siblings, 1 reply; 5+ messages in thread
From: ts @ 2003-10-05 16:33 UTC (permalink / raw
To: ruby-core; +Cc: ruby-core
>>>>> "C" == Christoph <chr_news@gmx.net> writes:
C> p proc {|| 13 }.arity # 0
C> p proc { 13 }.arity # -1
svg% ruby -e 'a = proc { p 12 }; a[1,2,3]; b = proc {|| 13 }; b[1]'
12
-e:1: wrong number of arguments (1 for 0) (ArgumentError)
from -e:1:in `[]'
from -e:1
svg%
Guy Decoux
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: arity bug?
2003-10-05 16:33 ` ts
@ 2003-10-05 16:55 ` Christoph
2003-10-05 23:57 ` Yukihiro Matsumoto
0 siblings, 1 reply; 5+ messages in thread
From: Christoph @ 2003-10-05 16:55 UTC (permalink / raw
To: ruby-core
"ts" wrote:
...
> svg% ruby -e 'a = proc { p 12 }; a[1,2,3]; b = proc {|| 13 }; b[1]'
> 12
> -e:1: wrong number of arguments (1 for 0) (ArgumentError)
> from -e:1:in `[]'
> from -e:1
> svg%
I known that the calling convention is consistent with the arity
but since there is no way of accessing the calling arguments
inside a Proc call like
proc { p 12 }[12,13]
it feels that the arity of these Proc's is 0 and not the current -1.
/Christoph
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: arity bug?
2003-10-05 16:55 ` Christoph
@ 2003-10-05 23:57 ` Yukihiro Matsumoto
2003-10-08 20:21 ` Christoph
0 siblings, 1 reply; 5+ messages in thread
From: Yukihiro Matsumoto @ 2003-10-05 23:57 UTC (permalink / raw
To: ruby-core
Hi,
In message "Re: arity bug?"
on 03/10/06, "Christoph" <chr_news@gmx.net> writes:
|I known that the calling convention is consistent with the arity
|but since there is no way of accessing the calling arguments
|inside a Proc call like
|
|proc { p 12 }[12,13]
|
|it feels that the arity of these Proc's is 0 and not the current -1.
Why don't you specify parameters explicitly if you want to get the
argument. Omitting parameters means "don't care".
matz.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: arity bug?
2003-10-05 23:57 ` Yukihiro Matsumoto
@ 2003-10-08 20:21 ` Christoph
0 siblings, 0 replies; 5+ messages in thread
From: Christoph @ 2003-10-08 20:21 UTC (permalink / raw
To: ruby-core
Yukihiro Matsumoto wrote:
..
> |proc { p 12 }[12,13]
> |
> |it feels that the arity of these Proc's is 0 and not the current -1.
>
> Why don't you specify parameters explicitly if you want to get the
> argument. Omitting parameters means "don't care".
But if I don't provide explicit parameters at definition time
I see little reason why it should be allowed to supply superfluous
parameters at calling time.
Anyway it is no big deal (arity = -1 works fine in any occasion) and
it probably worked like this for ages - I just was really surprised when
I finally tripped over this fact.
/Christoph
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2003-10-08 20:19 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-10-05 16:29 arity bug? Christoph
2003-10-05 16:33 ` ts
2003-10-05 16:55 ` Christoph
2003-10-05 23:57 ` Yukihiro Matsumoto
2003-10-08 20:21 ` Christoph
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).