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

Update tutorial to show new lambda syntax. #166

Merged
merged 1 commit into from
Nov 7, 2016

Conversation

jemc
Copy link
Member

@jemc jemc commented Nov 6, 2016

This PR updates the tutorial to show the new lambda syntax. It also makes some corrections around some details about lambdas.

See ponylang/ponyc#1400 for the implementation of the change.

Also makes some corrections around some details about lambdas.
try
f(l.shift())
for_each(l, f)
end
```

This example declares the type of the apply function that is generated by the lambda expression as being `ref`. The type declaration for it in the `for_each` method also declares it as `ref`. The lambda function captures some variables so the object that is generated is `ref` and the default for the type declaration is `ref` so everything type checks.
This example declares the type of the apply function that is generated by the
lambda expression as being `ref`. The lambda type declaration for the `f` parameter in the `for_each` method also declares it as `ref`. The reference capability of the lambda type must also be `ref` so that the method can be called. The lambda object does not need to declare an explicit reference capability because `val` is the default for a lambda that has captures.
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't the last sentence say that ref is the default for a lambda that has captures?

Copy link
Member Author

Choose a reason for hiding this comment

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

Good catch, it was a copy-paste mistake. Fixed and squashed.

@Theodus Theodus merged commit 8970918 into master Nov 7, 2016
jemc added a commit that referenced this pull request Nov 7, 2016
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