Motoko needs less parentheses (tweet) #4830
ggreif
started this conversation in
Show and tell
Replies: 1 comment
-
|
Scheduled for publication May 16th |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
In many languages their grammar necessitates parentheses in many places to make them unambiguously parseable. In Motoko you can get away with much less. The rule of thumb is that if there is that single thing in parentheses, then the parentheses are probably redundant. E.g.
#err einstead of#err(e),if tracked {...}instead ofif (tracked) {...}. Same forswitch d,case null, etc. You can even call functions in Bash-style:foo argand define lambdas asfunc p = ...when the pattern is just a single token, though you have to consider whether your audience is okay with that!Beta Was this translation helpful? Give feedback.
All reactions