Brian's Waste of Time

Sun, 16 Oct 2005

From RubyConf: Day 2

Matz offered a number of options for lambda (anonymous function) creation syntax during his keynote. Figure I can comment as some of the thoughts are subtle. My gut reaction was to stick with lambda but something itched. I think I figured it out, but let's look at options.

f = lambda (x=5) 
  puts x 
end

f = lambda (x=5) { puts x }

f = -> (x=5) { puts x }

f = (x=5) { puts x }

f = def (x=5)
  puts x
end

The thing that bugged me about *all* of these is that the default value for the parameter (x=5) looks like it is being evaluated, not like a default value. This highlights, for instance, a big difference between python and ruby, in python the (x=5) is a statement, not an expression, and isn't the default in that context. I dislike this about python.

Oddly enough, the syntax I like the least, f = -> (x=5) { puts x } is probably the clearest for this as, visually, the arrow looks like it pushes the parens into the function def, kind of. Really, I want the params to be inside the block, I think, like the current goal posts. One thing suggested by the audience was the groovy method, f = { x=5 -> puts 5 }, which I quite like, and Matz thought about, but dismissed as looking too much like a hash ( { :x => 5 }, which it does, I agree =(

Blocks and anonymous functions will remain different, and I certainly trust Matz on this, though I don't see the reasoning personally =) If they are, then... maybe something block like is good. Matz seems pretty set on having parens for the args outside of the block, and I cannot say I disagree -- I just don't want the confusion over whether (x=5) is an assignment in the scope of the definition, or a default value in the scope of the invocation (execution in aspectj terms).

Aside from that, fantastic presentations by Ryan Davis and Jim Weirich on cool ruby hacks in the afternoon, nice (and really interesting) case studies in the morning. I had the advantage of sitting next to one of the Io hackers (Brian Mitchell) most of the day, so picked his brain some, and played with Io. Interesting. Also installed Forth based on breakfast conversation. Have to muck with a language described as "kind of low level -- higher than assembly, lower than C" =) Slate still wins the "my brain hurts the most" award, so I doubt I'll stop focusing the majority my language muckery on it for the most part for a while =)

0 writebacks [/tech/rubyconf05] permanent link

Sat, 15 Oct 2005

From RubyConf: Day 1

RubyConf has been fun, sleepy (got in late, woke up early, still on east coast time, but great fun =) Obie has been doing good presentation-by-presentation coverage, so I'll let him cover that. ;-)

SASADA Koichi is a fantastic presenter, and seeing how he is designing YARV was very interesting. I just wish I'd had more sleep. I need to dig through his presentation and try to remember some more C. I agree with him about block syntax in Ruby 2.0 =)

JRuby's progress is really interesting, the fact that it is being modeled on CISC and will be stackless via CPS is really cool. JRuby is definately alive and kicking.

On the flight and in some downtime today I've been beating on the ruby stomp client as well. Finally got a grip and started doing it right -- most of the old code has been thrown away and am doing it properly TDD this time. Basic client exists (it is that easy), but am still working on a better rubyomatic api.

0 writebacks [/tech/rubyconf05] permanent link

Fri, 14 Oct 2005

Off I Go...

To RubyConf and then to Palo Alto. Flight left almost on time, but is long =( Will give me time to rewite the ruby stomp client on the plane, I hope to release this weekend =)

1 writebacks [/tech/rubyconf05] permanent link