articles/smalltalk.md: add syntax postcard example

This commit is contained in:
tocariimaa 2025-03-09 19:28:55 -03:00
parent f389d2f380
commit 40e0a73ada

View file

@ -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