On 2/27/08, Laurent Sansonetti <laurent.sansonetti / gmail.com> wrote:
> Hi,
>
>  I am honored to announce the beginning of the MacRuby project!
>
>  MacRuby is a version of Ruby that runs on top of Objective-C. More
>  precisely, MacRuby is currently a port of the Ruby 1.9 implementation
>  for the Objective-C runtime and garbage collector.
>
>  You can learn more about the project on its homepage:
>
>  http://trac.macosforge.org/projects/ruby/wiki/MacRuby
>
>  MacRuby is still extremely experimental, but a first release is
>  expected very soon.

Interesting stuff.

After reading some of the material on the macosforge wiki, I'm curious
about the keyed arguments design.

It sounds like if I invoke a method like this:

    x.foo(1, bar: 2)

Then what happens is that this gets turned into an
Objective-C/Smalltalk syntax message selector of foo:bar:, but if I
use
    x.foo(1, 2, bar: 3)

then it effectively uses a different selector and uses Ruby parameter
semantics with bar: 3 getting mapped into {:bar => 3} the way Ruby 1.9
does it.

So what happens if I write a ruby class like this:

class C
   def foo(*a)
        keywords = a.pop if Hash === a.last
        ...
   end
end

And then, possibly in a separate file, write

def quack(duck)  # duck might be an instance of C, but is it?
    duck.foo(1, 2, bar: 3)  # I guess this would work in any case.
    duck.foo(1, bar: 2)      #  mapped to foo:bar: what does an
instance of C do with this?
end

This also seems to be treading on some of the territory which Matz has
indicated he plans to be defining in Ruby 2.0.  I'm worried that
there's a fork down the road here.

-- 
Rick DeNatale

My blog on Ruby
http://talklikeaduck.denhaven2.com/