strictures and structures

if only we stopped trying to be happy, we could have a pretty good time

Month: August, 2010

i will put parentheses everywhere now.

I wish Ruby had mandatory parentheses. These are the two reasons why:

1. def waltz(*args)

def hustle(*args)

hustle waltz 1, 2, 3, 4

What if I’d intended hustle(waltz(1, 2), 3, 4))? I recently broke
the sign up button on the home page (dear TechCrunch, that
broken code never got deployed if you’re curious) because there had
been no parentheses in a piece of code where one helper was calling
the result of another helper. It looked something like: hustle
waltz(long_parameter_name, another_long_parameter_name,
:long_parameter_name => long_value), another_complicated_parameter. I
think that while Ruby often looks better this way, it can encourage
code that’s hard to read for later maintainers. Or maybe I’m just

2. Wouldn’t it be nice if I could just do this:
def polka(one, two, three, four)

def frack(fn, one, two)
fn(one, two)

frack(polka, one, two)

Due to the optional parentheses, Ruby evaluates any mention of a
function as an actual attempt to call it and complains about missing
parameters if you try to refer to a function by just its name. If
parentheses were mandatory, you could pass around functions quite
easily, but instead, we have to jump through these hoops:

def frack(one, two, &fn)
yield(one, two)

frack(one, two) { |a, b| polka(a, b) }

I’ve never had to pass around a named function, mostly because I
can just use blocks. Still, this seems like shockingly revolting
syntax for something that really ought to be rather easy.

Comments? I’d be glad to hear other thoughts. Also, if there
really is an easier way to pass around a function than wrapping it in
a Proc, block, or lambda, please embarrass me. I want to know.

a retrospection

Six more days, and it will be the anniversary of our arrival at
Portsmouth, New Hampshire, from Astoria, Oregon. 3,629 miles by
bicycle. I think that was one of the lightest, happiest days of my
life. The weather that day was the best ever, even if some less
sentimental corner of my memory thinks that it was really hot and
humid, less than ideal.

Did I get what I was hoping to get out of it? I don’t know. Probably
not. I’m still not the equivalent of someone who did cross-country in
high school. I have more defined leg muscles, but I still get passed
on the road. I have some old enemies in the hills of Portola Valley
and Woodside, and sadly, I increased my time on them by only a couple
minutes. And I didn’t figure anything out about what I want to do with
my life, nothing about how to slay those demons peculiar to the
chambers of my heart. I thought I would learn something about this
country I’m in, but the sagebrush of Wisconsin and the soybean and
corn fields of Michigan were strangely silent.

It doesn’t matter.

I met another fellow trans-American cyclist, Martin, by a grocery
store the other day. He caught my eye because he was riding a
ludicrous bicycle–the front wheel was perhaps five feet in diameter,
and the rear wheel maybe two feet in diameter. The whole thing looked
like it deserved a rusty retirement in some colonial museum, but he
had pressed it into active service nonetheless. He was planning
what–his fifth or sixth trek across?–on that old bigwheel. He had
been older than I was when he made his first journey across, and he
told me something that I haven’t forgotten, and will never forget:

“You’ll find that this is an experience which shapes your perception
of everything else, and you’re lucky to have done this so young.
You’ll have many more years than I will to be guided by that

And he’s right. Going across was a gift that I’ll be unwrapping for
years to come.