3 ms·
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
by draegtun 15y ago
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) 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/ http://iolanguage.com/about/faq/
- eterps 15y agoSo, what would the syntax be in Io? Like this? valid := base bottom between(ligature bottom + height, base top / scale factor)
- draegtun 15y agoYes, 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)
- pupeno 15y agoAs far as I know both Self and Slate are very strongly inspired by Smalltalk.
- treetrouble 15y agoThank you, I wasn't familiar with Io before
- draegtun 15y agoYour 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/ http://iolanguage.com/about/samplecode/
- schrototo 15y agoJust 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]];