ruby-dev summary 23566-23622

Discussion in 'Ruby' started by Takaaki Tateishi, Jun 2, 2004.

  1. Hello,

    The following is a summary of ruby-dev.

    ruby-dev:23566-23622

    [ruby-dev:23616] [Oniguruma] Version 3.1.0 and 2.2.9

    Kosako announced the new release of Oniguruma, which is a regular
    expression matching engine working with ruby.

    [ruby-dev:23572] keyword argments (Ruby2.0 spec)

    Nagai asked how keyword arguments and hash-style arguments work in
    ruby-2.0, since a lot of hash-style arguments appear in his extension
    library 'Ruby/Tk'. Matz proposed following two solutions.
    (a) hash-style argument appearing at the end of argument list is
    supported as usual.
    (b) hash-style arguments were abolished.
    Nagai chose a case for (b) because of rapid shift to ruby-2.0.

    [ruby-dev:23567] for smoother extending PStore

    Nishiyama posted a patch for smoother extending PStore#dump and
    PStore#load. This change is useful for implementation of YAML::Store.
    --
    Takaaki Tateishi <>
     
    Takaaki Tateishi, Jun 2, 2004
    #1
    1. Advertising

  2. Takaaki Tateishi

    Paul Brannan Guest

    On Thu, Jun 03, 2004 at 12:00:51AM +0900, Takaaki Tateishi wrote:
    > [ruby-dev:23572] keyword argments (Ruby2.0 spec)
    >
    > Nagai asked how keyword arguments and hash-style arguments work in
    > ruby-2.0, since a lot of hash-style arguments appear in his extension
    > library 'Ruby/Tk'. Matz proposed following two solutions.
    > (a) hash-style argument appearing at the end of argument list is
    > supported as usual.
    > (b) hash-style arguments were abolished.


    I'd prefer (a), because backward-compatibility is a good thing, and I'd
    prefer to change my code as little as possible to make it work on Ruby
    2.0.

    But how would (a) work? It seems like it would make the following
    ambiguous:

    def foo(foo, bar=2)
    end

    foo:)foo => 14, :bar => 92)

    (is this calling foo with a hash and leaving bar with default argument,
    or is it calling foo with foo equal to 14 and bar equal to 92?)

    If (b) is chosen, it would be nice if hash-style arguments were
    deprecated for a version between current and 2.0.

    > Nagai chose a case for (b) because of rapid shift to ruby-2.0.


    I don't understand. What is meant by "rapid shift to ruby-2.0"?

    Paul
     
    Paul Brannan, Jun 2, 2004
    #2
    1. Advertising

  3. Paul Brannan wrote:
    > On Thu, Jun 03, 2004 at 12:00:51AM +0900, Takaaki Tateishi wrote:
    >
    >>[ruby-dev:23572] keyword argments (Ruby2.0 spec)
    >>
    >> Nagai asked how keyword arguments and hash-style arguments work in
    >> ruby-2.0, since a lot of hash-style arguments appear in his extension
    >> library 'Ruby/Tk'. Matz proposed following two solutions.
    >> (a) hash-style argument appearing at the end of argument list is
    >> supported as usual.
    >> (b) hash-style arguments were abolished.

    >
    >
    > I'd prefer (a), because backward-compatibility is a good thing, and I'd
    > prefer to change my code as little as possible to make it work on Ruby
    > 2.0.


    I'd vote for (a), too. I use this syntax as part of the programmer's
    interface of a simulation language embedded in ruby. So it's not a just
    matter of updating my own code, but of changing the interface that users
    see.

    Here's an example of code written in this embedded language:

    class C
    flow { diff "x' = 1" } # Runge-Kutta integration
    transition State1 => State2, State3 => State4 do
    guard "x > 2"
    reset :x => 0
    end
    end

    It just doesn't look the same with

    transition State1: State2 do ...

    or

    reset x: 0

    But maybe I've relied too much on an incidental aspect of ruby syntax... :(
     
    Joel VanderWerf, Jun 2, 2004
    #3
  4. Hi,

    From: "Takaaki Tateishi" <>
    Subject: ruby-dev summary 23566-23622
    Date: Thu, 3 Jun 2004 00:00:51 +0900
    Message-ID: <3666.61.23.130.160.1086188445.squirrel@61.23.130.160>
    > [ruby-dev:23572] keyword argments (Ruby2.0 spec)
    >
    > Nagai asked how keyword arguments and hash-style arguments work in
    > ruby-2.0, since a lot of hash-style arguments appear in his extension
    > library 'Ruby/Tk'. Matz proposed following two solutions.
    > (a) hash-style argument appearing at the end of argument list is
    > supported as usual.
    > (b) hash-style arguments were abolished.
    > Nagai chose a case for (b) because of rapid shift to ruby-2.0.


    I chose the solution (a) at [ruby-dev:23624]. :)
    --
    Hidetoshi NAGAI ()
     
    Hidetoshi NAGAI, Jun 2, 2004
    #4
  5. Takaaki Tateishi

    Guest

    Hi,

    At Thu, 3 Jun 2004 02:33:44 +0900,
    Paul Brannan wrote in [ruby-talk:102177]:
    > But how would (a) work? It seems like it would make the following
    > ambiguous:
    >
    > def foo(foo, bar=2)
    > end
    >
    > foo:)foo => 14, :bar => 92)
    >
    > (is this calling foo with a hash and leaving bar with default argument,
    > or is it calling foo with foo equal to 14 and bar equal to 92?)


    The former. The latter syntax will be

    foo(foo: 14, bar: 92)

    --
    Nobu Nakada
     
    , Jun 3, 2004
    #5
  6. wrote:
    > Hi,
    >
    > At Thu, 3 Jun 2004 02:33:44 +0900,
    > Paul Brannan wrote in [ruby-talk:102177]:
    >
    >>But how would (a) work? It seems like it would make the following
    >>ambiguous:
    >>
    >>def foo(foo, bar=2)
    >>end
    >>
    >>foo:)foo => 14, :bar => 92)
    >>
    >>(is this calling foo with a hash and leaving bar with default argument,
    >>or is it calling foo with foo equal to 14 and bar equal to 92?)

    >
    >
    > The former. The latter syntax will be
    >
    > foo(foo: 14, bar: 92)


    Lovely!

    So that means

    foo(bar: 1, :bar => 2)

    will pass two distinct arguments:

    1) the integer 1 in keyword argument "bar", and

    2) the hash {:bar => 2} ?

    I like it, even though it is a little inconsistent with

    irb(main):001:0> {bar: 1} == {:bar => 1}
    => true
    irb(main):002:0> RUBY_VERSION
    => "1.9.0"
     
    Joel VanderWerf, Jun 3, 2004
    #6
  7. Takaaki Tateishi

    Guest

    Hi,

    At Thu, 3 Jun 2004 09:40:58 +0900,
    Joel VanderWerf wrote in [ruby-talk:102226]:
    > So that means
    >
    > foo(bar: 1, :bar => 2)
    >
    > will pass two distinct arguments:
    >
    > 1) the integer 1 in keyword argument "bar", and
    >
    > 2) the hash {:bar => 2} ?


    I'm not sure whether it will be allowed, non-keyword arguments
    after keyword arguments.

    --
    Nobu Nakada
     
    , Jun 3, 2004
    #7
  8. il Thu, 3 Jun 2004 09:24:32 +0900, ha
    scritto::

    >Hi,
    >
    >At Thu, 3 Jun 2004 02:33:44 +0900,
    >Paul Brannan wrote in [ruby-talk:102177]:
    >> But how would (a) work? It seems like it would make the following
    >> ambiguous:
    >>
    >> def foo(foo, bar=2)
    >> end
    >>
    >> foo:)foo => 14, :bar => 92)
    >>
    >> (is this calling foo with a hash and leaving bar with default argument,
    >> or is it calling foo with foo equal to 14 and bar equal to 92?)

    >
    >The former. The latter syntax will be
    >
    > foo(foo: 14, bar: 92)


    sorry for asking again, but I went ignored the first time, this is the
    last time I try:
    Why we make a distinction beetween positional/default args and named
    args ?
    Being able to threat them equally would be much more useful I believe,
    cause it would allow smatrte usage of many of the existing libraries
    (say, all the GUI code)
     
    gabriele renzi, Jun 3, 2004
    #8
  9. Paul Brannan wrote:
    >>[ruby-dev:23572] keyword argments (Ruby2.0 spec)
    >>
    >> Nagai asked how keyword arguments and hash-style arguments work in
    >> ruby-2.0, since a lot of hash-style arguments appear in his extension
    >> library 'Ruby/Tk'. Matz proposed following two solutions.
    >> (a) hash-style argument appearing at the end of argument list is
    >> supported as usual.
    >> (b) hash-style arguments were abolished.

    >
    >
    > I'd prefer (a), because backward-compatibility is a good thing, and I'd
    > prefer to change my code as little as possible to make it work on Ruby
    > 2.0.


    But I suspect there will be lots of changes needed for Ruby 1.x source
    to work with Ruby2. For instance, as I understand, the syntax for hash
    literal will become:

    {'foo': 1, 'bar': 2}

    where in Ruby1.x it's:

    {'foo', 1, 'bar', 2}
    {'foo' => 1, 'bar' => 2}

    I suspect Ruby2 will forbid the latter?

    I use hash almost everywhere, so...

    --
    dave
     
    David Garamond, Jun 3, 2004
    #9
  10. On Thu, Jun 03, 2004 at 07:07:17PM +0900, David Garamond wrote:
    > Paul Brannan wrote:
    > >>[ruby-dev:23572] keyword argments (Ruby2.0 spec)
    > >>
    > >> Nagai asked how keyword arguments and hash-style arguments work in
    > >> ruby-2.0, since a lot of hash-style arguments appear in his extension
    > >> library 'Ruby/Tk'. Matz proposed following two solutions.
    > >> (a) hash-style argument appearing at the end of argument list is
    > >> supported as usual.
    > >> (b) hash-style arguments were abolished.

    > >
    > >
    > >I'd prefer (a), because backward-compatibility is a good thing, and I'd
    > >prefer to change my code as little as possible to make it work on Ruby
    > >2.0.

    >
    > But I suspect there will be lots of changes needed for Ruby 1.x source
    > to work with Ruby2. For instance, as I understand, the syntax for hash
    > literal will become:
    >
    > {'foo': 1, 'bar': 2}
    >
    > where in Ruby1.x it's:
    >
    > {'foo', 1, 'bar', 2}
    > {'foo' => 1, 'bar' => 2}
    >
    > I suspect Ruby2 will forbid the latter?


    No, both will work.

    {a: 1} in Ruby >= 1.9 is just a short form for {:a => 1} or at least
    that's how I understood it.

    Regards,

    Michael
     
    Michael Neumann, Jun 3, 2004
    #10
  11. il Thu, 3 Jun 2004 19:07:17 +0900, David Garamond
    <lists@zara.6.isreserved.com> ha scritto::

    >But I suspect there will be lots of changes needed for Ruby 1.x source
    >to work with Ruby2. For instance, as I understand, the syntax for hash
    >literal will become:
    >
    > {'foo': 1, 'bar': 2}
    >
    >where in Ruby1.x it's:
    >
    > {'foo', 1, 'bar', 2}
    > {'foo' => 1, 'bar' => 2}
    >
    >I suspect Ruby2 will forbid the latter?
    >


    the old syntax should remain. But in addition you get:

    foo: bar
    that would mean:
    :foo => bar
     
    gabriele renzi, Jun 3, 2004
    #11
  12. Takaaki Tateishi

    Guest

    Hi,

    At Fri, 4 Jun 2004 00:06:07 +0900,
    Austin Ziegler wrote in [ruby-talk:102289]:
    > Where will the ** notation fit in? Will it be:
    >
    > foo(** :foo => 14, :bar => 92)
    > foo(**{ :foo => 14, :bar => 92 })


    As well as *array, it prefixes an expression. So the former
    wouldn't be valid syntax.

    > And this will effectively make one of those two:
    >
    > > foo(foo: 14, bar: 92)

    >
    > ?


    AFAIK, it will.

    --
    Nobu Nakada
     
    , Jun 3, 2004
    #12
  13. Takaaki Tateishi

    Guest

    Hi,

    At Thu, 3 Jun 2004 19:09:59 +0900,
    gabriele renzi wrote in [ruby-talk:102251]:
    > >At Thu, 3 Jun 2004 02:33:44 +0900,
    > >Paul Brannan wrote in [ruby-talk:102177]:
    > >> But how would (a) work? It seems like it would make the following
    > >> ambiguous:
    > >>
    > >> def foo(foo, bar=2)
    > >> end
    > >>
    > >> foo:)foo => 14, :bar => 92)
    > >>
    > >> (is this calling foo with a hash and leaving bar with default argument,
    > >> or is it calling foo with foo equal to 14 and bar equal to 92?)

    > >
    > >The former. The latter syntax will be
    > >
    > > foo(foo: 14, bar: 92)

    >
    > Why we make a distinction beetween positional/default args and named
    > args ?


    This is not that distinction, but between hash literal and
    named args.

    --
    Nobu Nakada
     
    , Jun 4, 2004
    #13
    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. Kazuo Saito

    ruby-dev summary 20418 - 20487

    Kazuo Saito, Jul 1, 2003, in forum: Ruby
    Replies:
    0
    Views:
    91
    Kazuo Saito
    Jul 1, 2003
  2. TAKAHASHI Masayoshi

    ruby-dev summary 20489 - 20519

    TAKAHASHI Masayoshi, Jul 9, 2003, in forum: Ruby
    Replies:
    0
    Views:
    96
    TAKAHASHI Masayoshi
    Jul 9, 2003
  3. Kazuo Saito

    ruby-dev summary 20715-20940

    Kazuo Saito, Jul 29, 2003, in forum: Ruby
    Replies:
    0
    Views:
    103
    Kazuo Saito
    Jul 29, 2003
  4. TAKAHASHI Masayoshi

    ruby-dev summary 20941-21133

    TAKAHASHI Masayoshi, Aug 7, 2003, in forum: Ruby
    Replies:
    0
    Views:
    98
    TAKAHASHI Masayoshi
    Aug 7, 2003
  5. Shashank Date

    ruby-dev summary 21134-21191

    Shashank Date, Aug 14, 2003, in forum: Ruby
    Replies:
    2
    Views:
    102
    NAKAMURA, Hiroshi
    Aug 15, 2003
Loading...

Share This Page