Forum: JRuby Accessors arity in MRI and JRuby

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.
B63501aa235ec0a016402b3d78543088?d=identicon&s=25 Andrea Fazzi (remogatto)
on 2009-05-31 23:31
(Received via mailing list)
Hi all,

I noticed a difference in the arity of accessors between MRI and JRuby:

# MRI

VERSION = 1.8.6-p287
CMD     = ~/.multiruby/install/1.8.6-p287/bin/ruby -S irb

irb(main):001:0> class Foo
irb(main):002:1> attr_accessor :bar
irb(main):003:1> end
=> nil
irb(main):004:0> Foo.new.method(:bar=).arity
=> 1

# JRuby

irb(main):001:0> class Foo
irb(main):002:1> attr_accessor :bar
irb(main):003:1> end
=> nil
irb(main):008:0> Foo.new.method(:bar=).arity
=> -1

JRuby returns -1 for the accessor :bar while MRI 1.8.6 returns 1. What's
the meaning of this difference?

Thanks in advance.
Andrea



---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email
Ede2aa10c6462f1d825143879be59e38?d=identicon&s=25 Charles Oliver Nutter (Guest)
on 2009-05-31 23:42
(Received via mailing list)
Andrea Fazzi wrote:
> Hi all,
>
> I noticed a difference in the arity of accessors between MRI and JRuby:
...
> JRuby returns -1 for the accessor :bar while MRI 1.8.6 returns 1. What's
> the meaning of this difference?

Probably nothing; we should fix our accessors to be arity 1.

- Charlie

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email
Ede2aa10c6462f1d825143879be59e38?d=identicon&s=25 Charles Oliver Nutter (Guest)
on 2009-06-01 00:13
(Received via mailing list)
I have a fix for this ready. Would it be possible for you to add some
arity specs to RubySpec, for this and for some other cases? And of
course, a JRuby bug should be filed :)

Andrea Fazzi wrote:
> irb(main):002:1> attr_accessor :bar
> => nil
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>     http://xircles.codehaus.org/manage_email
>
>


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email
B63501aa235ec0a016402b3d78543088?d=identicon&s=25 Andrea Fazzi (remogatto)
on 2009-06-01 12:41
(Received via mailing list)
Il giorno dom, 31/05/2009 alle 15.13 -0700, Charles Oliver Nutter ha
scritto:
> Would it be possible for you to add some
> arity specs to RubySpec, for this and for some other cases? And of
> course, a JRuby bug should be filed :)

Hi Charles,

yes it's possible but I need some time to get confident with the
RubySpec project. Meanwhile I'll open a ticket for the bug on codehaus.

Andrea



---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email
This topic is locked and can not be replied to.