Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

The syntax is quite unique to Smalltalk. The message, otherwise known as “method call” in other languages, is called show: (including the colon) and it takes an argument.

self also uses this method call syntax. However this syntax can get quite confusing, see this example from http://en.wikipedia.org/wiki/Self_(programming_language)

  valid: base bottom between: ligature bottom + height and: base top / scale factor.
Smalltalk version provided gets even more verbose:

  valid := self base bottom between: self ligature bottom + self height and: self base top / self scale factor.
Personally I prefer Io message syntax because it has far less ambiguity. See Why not use an infix message syntax like Smalltalk? in the FAQ - http://iolanguage.com/about/faq/


Just for comparison's sake, here's the version in everyone's favorite bastard child of Smalltalk and C, Objective-C:

  valid = [self baseBottomBetween:[self ligatureBottom]+[self height] and:[self base]];


So, what would the syntax be in Io? Like this?

  valid := base bottom between(ligature bottom + height, base top / scale factor)


Yes, unless I've totally misunderstood that Self/Smalltalk code!

Also instead of between method with two args you could also create an and message/method:

  valid := base bottom between(ligature bottom + height) and(base top / scale factor)


As far as I know both Self and Slate are very strongly inspired by Smalltalk.


Thank you, I wasn't familiar with Io before


Your very welcome. Like Smalltalk, its a beautifully designed language.

Some quick examples:

  10 repeat("Hello world" println)

  (y < 10) ifTrue(x := y) ifFalse(x := 2)

  if (y < 10, x := y, x := 2)
More example Io code can be found here: http://iolanguage.com/about/samplecode/




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: