5 ms·
Smalltalk's "become" is a pretty interesting one... http://gbracha.blogspot.it/2009/07/miracle-of-become.html http://gbracha.blogspot.it/2009/07/miracle-of-beco
by antirez 13y ago
Smalltalk's "become" is a pretty interesting one... http://gbracha.blogspot.it/2009/07/miracle-of-become.html http://gbracha.blogspot.it/2009/07/miracle-of-become.html
- saryant 13y agoAkka actors have a very similar feature, same name. It doesn't swap identities though. It's actually pretty cool if you think of it as a way to track state without having a mutable variable. One example is this implementation of the dining philosophers problem: https://github.com/akka/akka/blob/master/akka-samples/akka-sample-fsm/src/main/scala/DiningHakkersOnBecome.scala https://github.com/akka/akka/blob/master/akka-samples/akka-s... You can also use "unbecome" and effectively treat an actor's behavior as a stack, popping and pushing receive functions. One cool trick is to bind a value to your receive function: def receive(foo: Foo): Receive = { ... } Then you can bind immutable data to a given receive function but think of it as mutable by replacing the current receive function with become().
- BrandonY 13y agoSmalltalk also is rather famous for giving developers enough freedom to more or less destroy the environment with the terrifying looking command "Smalltalk := nil"
- rbanffy 13y agoI once crashed Squeak by making true := false. It was an interesting experience.