Motoko Grammar with Latest Features

Is there an updated Motoko Grammar doc with all of the latest features?

  • Multi-line strings
  • Non-consensus async* / await*
  • Optional else block for variable bindings
  • Piping operator |>
  • Collapsed switch branches
  • Composite queries

@claudio @matthewhammer @skilesare

2 Likes

This is the source file for that doc, and is up to date (by virtue of being in the Motoko compiler repo, and being generated from it mechanically):
https://github.com/dfinity/motoko/blob/master/doc/md/examples/grammar.txt

(I’m not sure about the cadence for pushing those changes into the published docs. Maybe @claudio or @Jessie knows?)

2 Likes

Thank you @matthewhammer. Much appreciated!

2 Likes

From my understanding, the submodule for Motoko in the Portal repo needs to be updated to the latest commit hash. It looks like the latest version is from May: https://github.com/dfinity/portal/tree/master/submodules

2 Likes

We tend to keep the portal documentation in sync with the version of motoko shipped with the latest official dfx release.

2 Likes

https://internetcomputer.org/docs/current/motoko/version should state the version that the doc corresponds to.

1 Like