Smalltalk syntax (and features) can be found pretty exotic (and even disturbing) when you come from a more C-like syntax world. I found myself losing time with some
I would be interested in learning knowing what you found really exotic compared to more classic/mainstream languages and that you think helps to understand the language.
For example, evaluation with logic operators :
(object1 = object2) & (object3 = object4)
: this will evaluate the whole expression, even if the left part is false, the rest will be evaluated.(object1 = object2) and: [object3 = object4]
: this will evaluate the left part, and only will evaluate the right part if the first is true.Everything is an object, and everything above the VM's available for inspection and modification. (Primitives are part of the VM, conceptually at least.) Even your call stack's available (thisContext
) - Seaside implemented continuations back in the day by simply swizzling down the call stack into a stream, and restoring it (returning to the continuation) by simply reading out activation frames from that stream!
You can construct a selector from a string and turn it into a Symbol
and send it as a message: self perform: 'this', 'That'
will do the same thing as self thisThat
. (But don't do this, for the same reasons you should avoid eval
in both Lisps and PHP: very hard to debug!)
Message passing: it's not method invocation!
#become:
is probably a bit of a shock to anyone who hasn't seen it before. (tl;dr a wholesale swapping of two object pointers - all references to B now point to A, and all references to A now point to B)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With