Io: my errno adventure in C

This pastie holds my first C patch. It actually repaired a Readline problem that appeared on my Mac when I git pull‘d Io’s source today. See the Io issue at their bugtracker.

The pgsql heroes fixed the problem way before, so I could stand on the shoulders of smart giants.

I don’t know how to test C stuff, except for running the programs, and Jonas reminded to actually do that:

c-5b66e555:~ olle$ rm .io_history
c-5b66e555:~ olle$ mkdir .io_history
c-5b66e555:~ olle$ io
Io 20080120

 Exception: while loading history file '/Users/olle/.io_history', reason: Is a directory
 ---------
 loadHistory                         Z_CLI.io 47
 ReadLine ?                           Z_CLI.io 47
 Call relayStopStatus                 A2_Object.io 295
 CLI loadHistory                      Z_CLI.io 94
 CLI interactiveMultiline             Z_CLI.io 82
 CLI run                              IoState_runCLI() 1

c-5b66e555:~ olle$

So, the complaining functionality is retained.

What’s it do?

For those who are beginners at C, like I am, this small digression might interest:

  • First we include the errno mechanism as an include: #include <errno.h>
  • in each function, initialize the value of the static global variable “errno” to 0
  • functions like read_history(filename), from the libedit library return an int, but…
  • We are not interested in the return value, so we cast the computation to be void, the errno mechanism will take care of remembering that int on its own
  • It seems to be culturally correct to check for success instead of failure.

All these factoids are guesstimates of what went on, and I’m interested in the real story someday. Please provide any insight as comments, dear reader.

PS: As you can tell, mucking about other people’s C code is not something I do every day. I felt good, but weird.

WideFinder in Io: it’s now too late

A Swede made the first WideFinder implementation in Io: Ragnar Dahlén.

The results were informative, but not performant. Io can not compete just there, just yet.

Me and Thorbiörn were conspiring last week to implement WideFinder, but we got waylaid by… distractions. The distractions were speculative, lazy, and touched on different OCamls. Like this: “We need an OCaml-shaped project. To help us learn.”

The usual get-started project is “Make an HTTP server than can 200 and 404. At least.” Hardly qualifies as OCaml-shaped…

Hack-a-thon, in my town!

More groups of people who want to fiddle with opensource software: Hackaton.se. They have an event in Malmö, at a school, 23-25 november.

Just to let you know, so you can spread the word. I’ll write more when I know more.

Update! An attentive reader, also being the organizer of the upcoming event emailed me, and told me more. It’s called “Hack-a-ton”, note the Scandinavian spelling. URL changed to reflect this.