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

Receiver capabilities of constructors not documented #212

Open
4 tasks
non-Jedi opened this issue Jul 28, 2017 · 5 comments
Open
4 tasks

Receiver capabilities of constructors not documented #212

non-Jedi opened this issue Jul 28, 2017 · 5 comments
Labels
good first issue Good for newcomers help wanted Extra attention is needed

Comments

@non-Jedi
Copy link
Contributor

non-Jedi commented Jul 28, 2017

  • Meaning of e.g. new ref create() should be explained.
  • It was mentioned on irc that new val create() would only accept sendable arguments. This should also be documented.
  • I assume that fun val foo() would also only accept sendable arguments. I don't think this is documented either.
  • Probably should add further explanation of default reference capability for a type and how it differs from using a constructor with a certain receiver capability.
@jemc
Copy link
Member

jemc commented Jul 28, 2017

I assume that fun val foo() would also only accept sendable arguments. I don't think this is documented either.

Actually, this one isn't a requirement. The reason we have that requirement for new val create is because it's roughly equivalent to a recover statement - the fields of the constructor are mutable inside the constructor body, but once it returns, the object is lifted to val. We have to require sendable arguments there for the same reason a recover statement can only allow sendable references from outside the block to be used inside the block - because otherwise a non-sendable could get embedded in the recovered sendable object, breaking capability safety.

For fun val this is not a problem because the receiver is treated as val inside the method body, so you can't assign anything to it or do anything else that break capabilities.

@SeanTAllen
Copy link
Member

Thoughts on where this would go @jemc?

@shelby3
Copy link

shelby3 commented Dec 4, 2018

It was mentioned on irc that new val create() would only accept sendable arguments. This should also be documented.

The reason we have that requirement for new val create is because it's roughly equivalent to a recover statement - the fields of the constructor are mutable inside the constructor body, but once it returns, the object is lifted to val.

Assuming class fields can’t be assigned from in a constructor (and noting that assigning from sendable arguments to non-sendable arguments is illegal), then I presume one of the reasons for not making an exception for constructor arguments which are only assigned to instead of assigned from, is because constructors really shouldn’t be encouraged to have side-effects? If so, then for consistency shouldn’t constructors (of all capability types) be forced to never assign to input arguments (or at least those which aren’t assigned from)?

I contemplated whether Pony has a feature to enforce referential transparency orthogonal to necessary degrees-of-freedom for reference capabilities. I pondered whether a function that takes mutable reference capabilities could possibly be referentially transparent. Contemplated whether conflating reference capabilities and referential transparency invariants would reduce degrees-of-freedom. Although a function which leaks a mutable reference capability in its return value is I guess not referentially transparent because the return value can mutate. Thus I guess box, val and tag arguments do cover the referentially transparent cases.

@jemc
Copy link
Member

jemc commented Jun 15, 2020

@SeanTAllen - I'm not sure the best place to put this, to be honest. We introduce methods and the idea of fun ref very early in the tutorial before we talk about reference capabilities at all, and we never really come back to talking about how receiver capabilities work in detail, for either for fun or new.

We probably need to add a new page to the "Reference Capabilities" section called "Receiver Capabilities" we talk about how receiver capabilities work in detail, for both fun and new.

@rhagenson
Copy link
Member

rhagenson commented Jun 15, 2020 via email

@aturley aturley added the help wanted Extra attention is needed label Jun 16, 2020
@rhagenson rhagenson added the good first issue Good for newcomers label Dec 16, 2020
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

6 participants