Two processes intend to add two to a number.
They each read the current value.
Then they each write back the value which is two bigger then the original.
If you instead use private fields and public getters/setters, or use actors to form a protective bubble around the mutable state, you get...
This article is about actors in the Swift programming language, and I’d answer the question (“is a stateless actor pointless?”) differently: there is no such thing as a stateless actor in Swift.
Every actor in Swift conforms to the Actor protocol, which has one requirement: an instance property named `unownedExecutor`. Swift uses this property implicitly when, for example, the program calls a method on the actor from outside the actor.
There is no language (yet) which makes fine-tuned for-purpose abstractions, of all familiar kinds, both trivial to specify and performant to run/compile.
So anyone coding anything interesting is almost certainly under or over using their languages' and libraries' abstractions.
Also, for highly composable languages, where null versions of almost anything make sense: Stateless states, operationless operations, destinationless network ports, storage roots not associated with any hardware, just "0 bytes", ... all make practical sense.
5 comments
[ 3.4 ms ] story [ 16.6 ms ] threadThe exact same thing but with more boilerplate.
Every actor in Swift conforms to the Actor protocol, which has one requirement: an instance property named `unownedExecutor`. Swift uses this property implicitly when, for example, the program calls a method on the actor from outside the actor.
https://developer.apple.com/documentation/swift/actor/unowne...
(One could also argue that, because every actor type is a reference type, every actor also has its identity as part of its state.)
Glad I checked the comments first, I had assumed it was stateless people that were actors. Stateless people are kind of an interesting topic.
So anyone coding anything interesting is almost certainly under or over using their languages' and libraries' abstractions.
Also, for highly composable languages, where null versions of almost anything make sense: Stateless states, operationless operations, destinationless network ports, storage roots not associated with any hardware, just "0 bytes", ... all make practical sense.