26 ms·
Io presents an interesting alternative. There are only Blocks (functions with assignable scope). Blocks have an activatable slot. If you set it to true, the blo
by richcollins 17y ago
Io presents an interesting alternative. There are only Blocks (functions with assignable scope). Blocks have an activatable slot. If you set it to true, the block is activated when an object receives a message that looks up the slot with the block. If false, it returns the block.
sayHello := block(“hello” println)
sayHello //returns the block
sayHello setIsActivatable(true)
sayHello //prints “hello”
getSlot(“sayHello”) //returns the block
http://www.iolanguage.com/scm/git/checkout/Io/docs/IoGuide.html#Objects http://www.iolanguage.com/scm/git/checkout/Io/docs/IoGuide.h...
- gfodor 17y agoWhoa. So much for the principle of least surprise!
- richcollins 17y agoIn practice, Io does follow the principle of least surprise. By default, blocks aren't activatable and methods are.
- gfodor 17y agoI'm talking about a higher meta-level: to me, it's surprising that the language semantics of what it means to simply type an identifier of a function change based upon the runtime state of the program. This seems crazy to me, it's like A New Kind of Side Effect I'd never seen before.
- richcollins 17y agoThis is called late binding, and it allows you more flexibility and productivity if you're willing to accept fewer constraints. Its actually quite powerful and allows some things that make Io a joy to work with. Memoization for instance: foo := method(foo = performSomeBigCalculation)
- awt 17y agoIo rocks :)