Ara.T.Howard wrote:
> it's not that big a deal to do is it?  i've abstracted this in alib like so:
>
>    harp:~ > cat a.rb
>    require 'alib'
>    include ALib::Util
>
>    def meth *argv
>      args, opts = optfilter argv
>      foo = getopt 'foo', opts
>      bar = getopt 'bar', opts, 'forty-two'  # default value
>
>      p 'args' => args
>      p 'opts' => opts
>      p 'foo' => foo
>      p 'bar' => bar
>    end
>
>    meth 'foo', 'bar', 'foo' => 42
>
>    harp:~ > ruby a.rb
>    {"args"=>["foo", "bar"]}
>    {"opts"=>{"foo"=>42}}
>    {"foo"=>42}
>    {"bar"=>"forty-two"}
>
>
> easy cheasy.  parseargs abstracts even further.

That's nice, but then why would we need key args if we'd do this
anyway?

> if a language mod must be
> made the answer seems clear: old style keywords land in *args as before, new
> style ones land in keys, for example:
>
>    def meth *args
>      p args
>    end
>
>    meth 42              #=> [42]
>    meth 42, 'foo' => 42 #=> [42, {'foo' => 42}]
>
>
>    def meth *args, **keys
>      p [args, keys]
>    end
>
>    meth 42                         #=> [ [42], {} ]
>    meth 42, 'foo' => 42            #=> [ [42, {'foo' => 42}], {} ]
>    meth 42, foo : 42               #=> [ [42, {}], {'foo' => 42} ]
>    meth 42, 'foo' => 42, foo : 42  #=> [ [42, {'foo' => 42}], {'foo' => 42} ]

>From what I understand this isn't what will happen, but rather

>    meth 42, foo : 42               #=> [ [42, {:foo => 42}], {:foo => 42} ]

and

>    meth 42, 'foo' => 42, foo : 42  #=> Error

> i might add that i hope whatever keys object will hash key and symbol
> arguments the same so we can do
>
>    val = keys['foo']
>
> or
>
>    val = keys[:foo]
>
> i hate having to check for both (that's what getopt above does).

Interesting point. Perhaps better then:

  val = keys.foo

Would go even better with Evan's mixed parameter object.

  def(*parms)
    p parms
    p parms.named
    p parms.foo
  end

  foo( 1,2,foo:3 )
  => [1,2]
     {:foo=>3}
     3

T.