Forum: IronRuby Code Review: arity

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Cb51033949ffccd982ae32c9f890f25a?d=identicon&s=25 Tomas Matousek (Guest)
on 2008-10-04 06:24
(Received via mailing list)
Attachment: arity.diff (600 KB)
tfpt review "/shelveset:arity;REDMOND\tomat"
Comment  :
  Fixes bugs in block parameters:
  1)    Anonymous unsplat parameters were not handled correctly (the
parser ignored them):
  def y
    a = [1,2,3,4,5]
    yield a,[6]
  end

  y { |(x,y,*),*| p x,y }
  2)    Arity wasn't calculated correctly. Arity depends upon AST
structure that is not preserved in runtime. Therefore we need to
calculate block arity at compile time and save it to BlockDispatcher.
  Some peculiar cases:

  Proc.new{|(a,b,c,*)|}.arity.should == -4
  Proc.new{|(*)|}.arity.should == -1
  Proc.new{}.arity.should == -1
  Proc.new{||}.arity.should == 0
  Proc.new{x,}.arity.should == 1
  Proc.new{(x,)}.arity.should == 1

Tomas
F983f0c990cba2fe743ef62a975ec99c?d=identicon&s=25 Curt Hagenlocher (Guest)
on 2008-10-05 07:20
(Received via mailing list)
Looks good.  One minor formatting problem: Some of the changed parts of
parser.y are now using tab characters instead of spaces.

In the BlockSignatureAttributes enumeration (in BlockDispatcher.cs),
there's a comment that "bits 31..3 store arity".  Are you numbering bits
from 1?  I'm used to numbering them from zero :).
This topic is locked and can not be replied to.