Document "self" in actor#2302
Closed
mzagozen wants to merge 1 commit into
Closed
Conversation
plajjan
reviewed
Jun 20, 2025
Comment on lines
+42
to
+46
| ## The implicit `self` in actors | ||
|
|
||
| Unlike classes where methods must explicitly declare `self` as their first parameter, actors have an implicit `self` that is automatically available. This fundamental difference means that actor methods are defined without a `self` parameter. In fact, using `self` as a parameter name in actor methods or in the actor's initialization arguments will result in an error. | ||
|
|
||
| The implicit `self` in an actor refers to the actor instance itself. This allows an actor to pass a reference to itself to another actor by simply passing `self`. This is particularly useful when implementing callback patterns or when an actor needs to register itself with another actor. |
Contributor
There was a problem hiding this comment.
I don't quite like this wording. It focuses on self is implicit, but self is just not needed to refer to attributes on the own actor.
The sole purpose of self in actor is to get an external view of the actor that we can pass to other actors that need to interact with us. I think we can express this much more concisely.
Collaborator
Author
There was a problem hiding this comment.
You are right, the section should focus on what you can not can't do with self :)
Contributor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of #2278.