Motoko needs less parentheses (tweet) #4830
ggreif
started this conversation in
Show and tell
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
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 e
instead of#err(e)
,if tracked {...}
instead ofif (tracked) {...}
. Same forswitch d
,case null
, etc. You can even call functions in Bash-style:foo arg
and 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