29 May 2011

Final day with Io. It’s been quite a ride, and even if I don’t think I grasp everything that Io is, I consider playing with Io a little bit on my own later because of it’s potential, especially in DSL.

Enhance the XML program to add spaces to show the indentation structure
Builder := Object clone
Builder depth := 0

Builder forward := method(
  prefix := "  " repeated(self depth)
  writeln(prefix, "<", call message name, ">")
  self depth = self depth + 1
  call message arguments foreach(arg,
    content := self doMessage(arg)
    if(content type == "Sequence", writeln(prefix, "  ", content))
  )
  self depth := self depth - 1
  writeln(prefix, "")
)

Builder html(head(title("Programing languages")), body(ul(li("IO"), li("Lua"), li("JavaScript"))))
Create a list syntax that uses brackets
curlyBrackets := method(
  l := List clone
  call message arguments foreach(arg,
    l append(doMessage(arg))
  )
  return l
)


blog comments powered by Disqus