Ruby2: keyword argument

Discussion in 'Ruby' started by David Garamond, Apr 20, 2004.

  1. Will Ruby2 support required keyword argument? AFAIR, Python doesn't:

    def foo(a, b=2):
    ...

    foo(a=1) # ok
    foo(a=1, b=2) # ok

    and Perl6 will:

    sub foo(+$a is required, +$b is required) {
    ...
    }

    # note: i'm not sure about the exact P6 syntax for calling
    foo(a: 1); # error!
    foo(a: 1, b: 2) # ok

    This is being discussed at perl6-language list right now. I also believe
    with the poster that basically said required keyword argument is
    essential for a "proper" keyword-based API.

    Also, implementation-wise, will the introduction of keyword arguments in
    Ruby2 bring a performance hit to all method calls, including positional
    arguments? (I.e., will normal/positional argument calls in Ruby2 be
    slower than Ruby1?)

    --
    dave
     
    David Garamond, Apr 20, 2004
    #1
    1. Advertising

  2. il Wed, 21 Apr 2004 00:34:14 +0900, David Garamond
    <lists@zara.6.isreserved.com> ha scritto::

    >Will Ruby2 support required keyword argument? AFAIR, Python doesn't:
    >
    > def foo(a, b=2):
    > ...
    >
    > foo(a=1) # ok
    > foo(a=1, b=2) # ok


    python does and so will ruby2.
    See matz slide from latest rubyconf for other info.
    basically, you'll write
    method(name: value)
    where name:value is the new hash literal for :name => value
     
    gabriele renzi, Apr 20, 2004
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Guest
    Replies:
    34
    Views:
    397
    Jim Freeze
    Aug 28, 2003
  2. Gavri Savio Fernandez

    Local Variable Scope in Ruby2

    Gavri Savio Fernandez, Nov 16, 2003, in forum: Ruby
    Replies:
    7
    Views:
    102
    Gavin Sinclair
    Nov 17, 2003
  3. David Garamond
    Replies:
    2
    Views:
    153
    Florian Gross
    Nov 21, 2003
  4. Lionel Thiry

    [ruby2] will '@@' disapear in ruby2?

    Lionel Thiry, Mar 12, 2005, in forum: Ruby
    Replies:
    12
    Views:
    176
    Lionel Thiry
    Mar 17, 2005
  5. Lionel Thiry
    Replies:
    3
    Views:
    117
    Lionel Thiry
    Apr 11, 2005
Loading...

Share This Page