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

Document let-punning in the manual #10202

Merged
merged 1 commit into from Feb 9, 2021
Merged

Conversation

stedolan
Copy link
Contributor

@stedolan stedolan commented Feb 8, 2021

Missing docs from #10013

@Octachron
Copy link
Member

You should also update the grammar at the start of the section on binding operators.

Copy link
Member

@gasche gasche left a comment

Choose a reason for hiding this comment

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

Thanks! This looks mostly good, see proposals for improvement.

manual/src/refman/extensions/bindingops.etex Outdated Show resolved Hide resolved
manual/src/refman/extensions/bindingops.etex Outdated Show resolved Hide resolved
@stedolan
Copy link
Contributor Author

stedolan commented Feb 8, 2021

@Octachron Good point, done.

The manual currently incorrectly documents the RHS of a let operator as a let-binding. There are three cases of let-binding:: value bindings, function bindings and polymorphic bindings.

  • Value bindings are the normal case let* x = foo in ...
  • Function bindings let* f x = ... in ... work but are not very useful. (In monadic code, they can only yield types like (a -> b) Monad.t, and can never be polymorphic)
  • Polymorphic bindings let* f : 'a . 'a -> 'a = ... in ... are a syntax error

I've defined letop-binding to include value bindings and punning, but left out the other two.

@Octachron
Copy link
Member

It seems fine to let the let* f x = ... case out of the simplified grammar described in the manual.

@Octachron Octachron merged commit 3d083ee into ocaml:trunk Feb 9, 2021
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.

None yet

3 participants