Skip to content

Document "self" in actor#2302

Closed
mzagozen wants to merge 1 commit into
mainfrom
actor-self
Closed

Document "self" in actor#2302
mzagozen wants to merge 1 commit into
mainfrom
actor-self

Conversation

@mzagozen

Copy link
Copy Markdown
Collaborator

Part of #2278.

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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right, the section should focus on what you can not can't do with self :)

@plajjan

plajjan commented Jun 23, 2025

Copy link
Copy Markdown
Contributor

Closing this in preference of #2314. TBH, this is AI-slop, it's changing examples that don't need changing, adds a new example that has little in common with the previous example and doesn't do a great job at explaining the key bit of self IMHO. #2314 does this simpler.

@plajjan plajjan closed this Jun 23, 2025
@plajjan plajjan deleted the actor-self branch June 23, 2025 06:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants