articles/smalltalk.md: add syntax postcard example
This commit is contained in:
parent
f389d2f380
commit
40e0a73ada
1 changed files with 22 additions and 0 deletions
|
@ -28,6 +28,28 @@ being able to contain the code of a program and its live state (similar to how s
|
||||||
- Smalltalk-80: most popular standard
|
- Smalltalk-80: most popular standard
|
||||||
- ANSI Smalltalk: released in 1998
|
- ANSI Smalltalk: released in 1998
|
||||||
|
|
||||||
|
## Smalltalk minimal syntax demostration
|
||||||
|
Unknown author.
|
||||||
|
```smalltalk
|
||||||
|
exampleWithNumber: x
|
||||||
|
|
||||||
|
"A method that illustrates every part of Smalltalk method syntax
|
||||||
|
except primitives. It has unary, binary, and keyword messages,
|
||||||
|
declares arguments and temporaries, accesses a global variable
|
||||||
|
(but not and instance variable), uses literals (array, character,
|
||||||
|
symbol, string, integer, float), uses the pseudo variables
|
||||||
|
true false, nil, self, and super, and has sequence, assignment,
|
||||||
|
return and cascade. It has both zero argument and one argument blocks."
|
||||||
|
|
||||||
|
|y|
|
||||||
|
true & false not & (nil isNil) ifFalse: [self halt].
|
||||||
|
y := self size + super size.
|
||||||
|
#($a #a "a" 1 1.0)
|
||||||
|
do: [:each | Transcript show: (each class name);
|
||||||
|
show: ' '].
|
||||||
|
^ x < y
|
||||||
|
```
|
||||||
|
|
||||||
## Implementations
|
## Implementations
|
||||||
- [Squeak](https://squeak.org/)
|
- [Squeak](https://squeak.org/)
|
||||||
- [Pharo](https://pharo.org/): fork of Squeak
|
- [Pharo](https://pharo.org/): fork of Squeak
|
||||||
|
|
Loading…
Add table
Reference in a new issue