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 usage of this more apparent #458

Open
gamebox opened this issue Jan 31, 2021 · 3 comments
Open

Make usage of this more apparent #458

gamebox opened this issue Jan 31, 2021 · 3 comments
Labels
good first issue Good for newcomers help wanted Extra attention is needed

Comments

@gamebox
Copy link

gamebox commented Jan 31, 2021

This probably is more revealing about me, but I went through the tutorial in order, and came out not understanding that classes, and more importantly for my usages that this was a thing.

My specific context was a tag reference of the current actor that could be sent to another actor so that they could have some bi-directional communication.

This was discussed in Zulip with @SeanTAllen (my zulip client on linux won't let me copy the link, sorry look in #beginner-help > "Self" reference for actors).

I think the sugar of not needing to use this when setting actor and class fields, or calling their methods and behaviors led me to not even think of it.
:
There is one reference in "Expression > Methods"

Functions are always called on an object. Again just specify the object, followed by a dot, followed by the name of the function to call. If the object to call on is omitted then the current object is used (i.e. this).

@jemc
Copy link
Member

jemc commented Feb 2, 2021

We discussed this a bit in today's sync call.

I suggest that we add an example to the https://tutorial.ponylang.io/types/actors.html page where we introduce actors, to show one actor calling another actor and using this to give a reference to itself, which the other actor uses to call it back.

@rhagenson
Copy link
Member

We also discussed what I am going to call the "usage curve of sugar" in the Tutorial. It was suggested that we remove sugar in early examples so the non-obvious is made obvious. My personal opinion on this is that, for learning, sugar is best used when we know we are working with new Pony users (as we are with the Tutorial). Manual desugaring is an intermediate step in fully understanding Pony. This is because, as we noted in the call today, forcing manual desugaring in early examples overcomplicates those examples for new users since cleaner, more easily understood examples with sugar can be written.

On this specific instance, this is not fully fixed by any "usage curve of sugar" as there is no sugar in it being needed for passing a self-reference across actor/object boundaries. I am in favor of adding a this-necessary example in the Concurrent subsection on the Actors page Joe posted to document self-reference passing.

Are there any other places in the Tutorial that we want to clarify the sugared usage of this? Perhaps in Classes for field access, or Methods so the existing i.e. parenthetical is more connected with the concept on that page?

@rhagenson
Copy link
Member

The link to the Zulip conversation is here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

4 participants