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

[Spec] sink parameter mutation #12641

Closed
mratsim opened this issue Nov 11, 2019 · 1 comment
Closed

[Spec] sink parameter mutation #12641

mratsim opened this issue Nov 11, 2019 · 1 comment

Comments

@mratsim
Copy link
Collaborator

mratsim commented Nov 11, 2019

It seems like sink parameter can be mutated.

This is actually very useful to me as for message passing a proc might want to take ownership of a message, update it and sink it into a channel. A var param would be needed otherwise and wouldn't be able to express the sink semantics.

i.e. this compiles

proc foo(x: sink int) =

  x += 1
  echo x

proc main() =
  var z = 3
  foo(z)


main()

However, this mutability of sink parameter is not clearly specified in the destructors spec.
If it's intentional, it should be added, if not it should be removed (and a sink var would be useful).

@mratsim
Copy link
Collaborator Author

mratsim commented Nov 11, 2019

Linked/duplicate of #12340

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant