Wednesday, February 15, 2006

C is like reading a really old book

I love C. Most people don't. Its like some folks prefer the old muscle cars and others like the new jap fizzbuckets. Don't get me wrong, I want to marry Ruby but C gives me a sense of oneness with the computer - I have ones and zeros in each hand :) A rarely used feature of C, where by you can embed methods within methods is a favourite of mine. A bit like ruby block/yields:

def user_active_count
count = 0
users.each { |e| count += 1 }
count
end

You can do this in C

void user_active_count() {
int count = 0;
void __inc_active_count(const void *nodep, const VISIT which, const int depth) {
if (which == postorder || which == leaf)
count ++;
}
twalk(_username_tree, __inc_active_count);
return count;
}

Beautiful, eh?

0 Comments:

Post a Comment

<< Home