Trans
7/20/2008 12:58:00 AM
On Jul 19, 5:13=A0pm, Roger Pack <rogerpack2...@gmail.com> wrote:
> > IDL does this and it's a pain for most situations, for instance
>
> > def foo a, b
> > =A0 =A0bar( ... )
> > end
>
> > def bar b, a
> > end
>
> > foo a : 4, b : 2
>
> > now foo has to have a method to return the named vars to bar, kinda
> > like *argv, but much more sophisticated, drastically reducing the
> > ability the sling around arrays and hashes in methods, especially for
> > method forwarding. =A0then there is the issue of required vs optional
> > parameters... =A0and code like this
>
> > =A0 =A0def foo options =3D {}
> > =A0 =A0 =A0add_defaults_to options
> > =A0 =A0 =A0bar options
> > =A0 =A0end
>
> > etc
>
> Yeah it definitely would reduce the ability to have ones own ending
> hash.
> That being said, you can always just pass on arguments in the standard
> way, a la
>
> def foo(a, b)
> =A0 bar(a, b)
> end
>
> But how that would interplay with *args, I don't know.
>
> My recommendation would be to be able to specify which methods have
> named arguments, so you know to expect them, and how to deal with them.
> Thoughts?
All I want is:
def foo(*args, **keys)
end
I am sooooooooooooooooooooooooooooo tired of:
def foo(*args_and_keys)
keys =3D (Hash=3D=3D=3Dargs_and_keys.last ? args.pop : {})
...
end
T.