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…

Io on OS X: Get a fixed libsgml

libsgml.zip is the libsgml library with a slightly modified build sequence, to accomodate the Mac OS X need for .dylib instead of .so files.

I learnt a bit on making Makefile.in and configure.in do my bidding, but don’t do this with your spare time. Try and download this file instead.

  • get the fixed libsgml, unpack it
  • make clean && ./configure && make
  • sudo make install
  • recompile your Io!
  • start io, and test:
  SGML; "<foo>bar</foo>" asXML

Update: I just took a look at this again, now on a newer Intel Mac. Here, there was trouble. There is a newer, better source code chunk at: http://www.hick.org/code/skape/libsgml/. Patch that instead. If and when I have something, I’ll post it here. It seems to be the LIBBIN line that irks.

  LIBBIN="\\${CXX} \\${DEBUG} -Wall -dynamiclib -install_name /usr/local/lib/libsgml.dylib -fPIC -o ../libsgml.dylib \\${OBJS}"

That was my blind try. And, it compiles a “dylib” alright. The install step is broken, though. I can not figure out how to get the Makefile.in to recreate the Makefile. That should happen on leaving the .configure.in, I think. Gotta learn more about this.

Update again: GNU Autoconf, Automake and Libtool helps understanding what those files are about. Now I have a little working knowledge, but my head’s spinning with all the things you could do with your Makefiles…

[tags]Io[/tags]

Io gets Ruby-style string interpolation

Io

This is nice for people who come to Io from Ruby: Io, the language, now has…

a C implementation of interpolate (by trevor with help from jer)

Just to give people a heads-up on this point. There is a slight
change in behaviour. Instead of using #io{...} to interpolate your
code, you now use #{...}. As well, instead of the string being
returned being mutable, it is now immutable.

Which is in the new tarball release.

Update: Whoops! You need to send an interpolate message to get the interpolation. Not like in Ruby, where it’s automatic. Thanks Jeremy Tregunna, for correcting! And for stopping by.

More Io Learning

[Io](http://www.iolanguage.com/)’s very self-documenting, at least when it comes to “what parameters does this and that take?” This is a little walk-through that gets you up and running in the interpreter. Get a binary from the downlaods page, and then come back here.

There is a docs slot — with some text about what the method does. First, let’s list a string (in Io, known as a Sequence, a sequence of characters, you know).

Whip out your Io interpreter, and write a string, and send the docs message to it:

Io> "olle" docs

==>  Object_0x6d5020:
  slots            = Object_0x6d5060

There we go, a memory address for the docs, and a list of slots. Open that!

Io> "olle" docs slots

==>  Object_0x6d5060:
  alignCenter      = Object_0x1120d90
  alignLeft        = Object_0x111fcf0
  alignLeftInPlace = Object_0x111e810
  alignRight       = Object_0x1120530
  findNthSeq       = Object_0x1121870
  interpolate      = Object_0x11222f0
  interpolateInPlace = Object_0x11226f0
  removeSeq        = Object_0x111f2d0
  repeated         = Object_0x6d4880

These contain documentation:

Io> "olle" docs slots repeated

==>  Object_0x6d4880:
  args             = List_0x6d4e20
  description      = "Returns a new sequence containing the receiver repeated aNumber number of times."

That is nice. But, there are many more methods on a Sequence. Where are the rest? Answer: not yet documented like this. Let’s go find the others.

Io> Sequence slotSummary

==>  "":
  ..               = method(arg, ...)
  afterSeq         = Sequence_afterSeq()
  alignCenter      = method(width, padding, ...)
  alignLeft        = method(width, padding, ...)
  alignLeftInPlace = method(width, padding, ...)
  alignRight       = method(width, padding, ...)
  append           = Sequence_append()
  appendPathSeq    = Sequence_appendPathSeq()
  appendSeq        = Sequence_appendSeq()
  asBinaryNumber   = Sequence_asBinaryNumber()
  asBuffer         = Sequence_asBuffer()
  asCapitalized    = Sequence_asCapitalized()
  asLowercase      = Sequence_asLowercase()
  asMessage        = Sequence_asMessage()
  asMutable        = Sequence_asMutable()
  asNumber         = Sequence_asNumber()
  asSimpleString   = method(...)
  asString         = Sequence_asString()
  asSymbol         = Sequence_asSymbol()
  asUppercase      = Sequence_asUppercase()
  at               = Sequence_at()
  atInsertSeq      = Sequence_atInsertSeq()
  atPut            = Sequence_atPut()
--- SNIPPED, FOR HER PLEASURE ---

That’s more like it! Notice the difference in the right-hand listing.

asNumber         = Sequence_asNumber()
asSimpleString   = method(...)

asNumber has a fast C implementation (the function name is a hint there), but asSimpleString is pure Io.

The Io-implemented methods have their argument list with them, like alignRight. The ellipsis (…) stands for the method body.

It’s possible to return any Io slot, serialized as a string. That includes all Io-implemented methods! Use the getSlot() method:

Io> Sequence alignRight getSlot("serialized")

==> method(b, if(b ==(nil), setSlot("b", Sequence clone));
b appendSeq(self asMutable replaceSeq("\"", "\\\"") asSimpleString))

So, Io has some documentation, and you can read much of the code in the interpreter.

The [online reference docs](http://iolanguage.com/docs/reference/browser.cgi) are not to be trusted, but they are helpful at times.