IO – Day 1
The group as a whole seems to have slowed down a bit on IO, with only a few of us sharing our Day 1 experiences. Installation has bitten a few people. I was lucky in that I was able to install it painlessly on OSX using Homebrew.
My next challenge with IO was figuring out the syntax for comments – turns out it’s a double slash: //
The homework: there was a lot of questions to answer, so I figured it was better to complete it in a blog post rather than a gist.
Stuff to find
I wasn’t sure if they are looking for puzzles to solve, or problems with the IO codebase. I couldn’t find the former, but here are some problems with the codebase: http://en.wikibooks.org/wiki/Io_Programming/Pitfalls
Questions to answer
- IO is strongly typed. The following commented out code causes an error because “one” is not a number.
- All are true:
- Use slotNames:
::= Creates slot, creates setter, assigns value := Creates slot, assigns value = Assigns value to slot if it exists, otherwise raises exception
The output of the slotNames in the code below reveals that Elf has the following slots: type, weapon, setWeapon, name
Stuff to Do
- To run an IO program from a file, just open terminal and type
- To execute the code in a given slot, simply call the slot.
Note: for the last piece of homework, I was trying to think of what to write code about. I recently moved into a new flat, and my new housemate has a small, very cute dog, who has just discovered a new game: fling his smackos under the bed, and then bark at it until she comes to retrieve it for him. I decided to write a very simplified version of that