Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make the "this" example in user-defined op docs more explicit #5179

Merged
merged 1 commit into from
Jul 11, 2024

Conversation

philrz
Copy link
Contributor

@philrz philrz commented Jul 10, 2024

In a community Slack thread, a user reported some struggles writing their first user-defined operator. In their own words:

I was trying to use switch in a user-defined operator this morning, and it was giving me a parsing error, because I was trying to pass this (essentially) as an argument of the op.
I figured out that if I’m just going to act on this inside the user-defined op, I don’t need an argument in that case.
Re-reading the docs, that’s somewhat evident now to me in the existing docs
but - the example here is so sparse, IMO, that I don’t think I grokked it very well.

After a little back & forth, we established that the minimal change of showing an explicit yield this instead of pass would have done the trick for him.

FWIW, in my usual slightly-more-verbose way, my first proposal was:

yield "I was called with " + string(this)

However, the user said that he was fine with either. Since the team members here tend to prefer examples that lean toward the minimal, that's what I'm proposing in the PR. But if folks actually prefer my other idea, I'm happy to go that way too. 😉

@philrz philrz requested a review from a team July 10, 2024 23:06
@philrz philrz self-assigned this Jul 10, 2024
@philrz philrz merged commit 6e61673 into main Jul 11, 2024
4 checks passed
@philrz philrz deleted the op-doc-this-improve branch July 11, 2024 21:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants