Enough prologue. Io is ridiculously tricky to search for on Google so I'm dropping links to my 'Find' results.
- Examples:
- Github gist, though some of them seem to be broken
- This blog post may not be the type of 'example' Mr Tate was thinking of, but it's going on my 'to be read' list anyway.
- Tutorials on the official language site
- Community: There's an official mailing list, twitter, and IRC channel. No idea how active they are. Otherwise, Stack Overflow is all I could find.
- Style guide: This wikibooks entry looks decent. No idea if there's anything more canonical. I'm not terribly perturbed about style right at the moment though. If I stay in Io long enough to have to find more resources I expect I'll find style canon alongside those searches.
Amusingly, many of my searches related to Io have turned up blogs of people, like me, working and blogging their way through this book. I find that quite amusing, though it highlights an apparent lack of external resources.
Anyway. On with the show. 'Answers'
- 1+1 runs, 1+"one" does not. 1 is a Number type and "one" is a Sequence type. Sequences don't respond to the + operator. On the other hand, an object can be assigned to any other object at will and according to the Io programming guide even inheritance can be changed at runtime. Which, it seems, would make Io very weakly typed.
- Everything is true. The cake is always honest. Unless cake := false clone or cake := nil clone. For proofs:
- true and 0
- ==> true
- true and ""
- ==> true
- true and nil
- ==> false
- true and false
- ==> false
- <Object> slotNames or perhaps <Object> proto slotNames. You can also send the slotSummary message to an object if you also want to know what's in each slot.
- = is assignment to a slot. := creates and assigns a slot (no unassigned variables, ever?) ::= creates and assigns a slot and defines an accessor method set<slotname>() in the object where <slotname> is the name of the slot with an upshifted first letter (existing catpitals are unchanged, only the first letter is upshifted).
So. Do:
- doFile("filename") filesystem context is where the Io binary is executed from, rather than where it resides. This can also be sent like any other message to an object.
- Execute the code in a slot given its name... I interpret that as 'how do you eval() a string'. Which is as so:
Bond := Object clone
Bond martini ::= nil
Bond orderMartini := "setMartini(\"shaken, not stirred\")"
Bond orderMartini := "setMartini(\"shaken, not stirred\")"
Bond slotSummary
Bond doString(Bond orderMartini)
Of course he might just have meant Bond setMartini("shaken, not stirred") or in words, send the slot name as a message to the object in order to execute the code in the slot. In fact, that's probably the simple answer that was being looked for. I tend to overcomplicate >.>
So far so good. I'm quite a bit more excited by Io than Ruby on D1.
No comments:
Post a Comment